summaryrefslogtreecommitdiff
path: root/src/saml2/config.py
diff options
context:
space:
mode:
authorJohn Paraskevopoulos <jpr@dialectics.space>2019-09-30 13:22:44 +0300
committerIvan Kanakarakis <ivan.kanak@gmail.com>2019-11-26 14:02:27 +0200
commitcc4526867734e40f3e413f309c450bb9033a871b (patch)
treea6caa568dd8138a3b818bedcf89b97fcc20955f1 /src/saml2/config.py
parent2109a65b1a233d42da84cc2aad982bf8a4b49816 (diff)
downloadpysaml2-cc4526867734e40f3e413f309c450bb9033a871b.tar.gz
Extract `PYSAML2_DELETE_TMPFILES` option to config.py
- Moves parsing PYSAML2_DELETE_TMPFILES option to config.py and uses the value as a Config class property (`delete_tmpfiles`). This attribute is part of the configuration so its place is in the config.py and the corresponding class. This may add the config object dependency to classes/functions that are calling the `make_temp` function, but at the same time keeps a more layered approach since this config option is now processed and set up in the correct layer; that is the Config class and the config module. Scripts that (in)directly use classes that have methods that use the `make_temp` functions were not changed since those methods are not called when these scripts run and they are out of the scripts' scope (that is, the script functionality does not create any temp file). Those scripts are `verify_metadata`, `merge_metadata` and `mdexport`
Diffstat (limited to 'src/saml2/config.py')
-rw-r--r--src/saml2/config.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/saml2/config.py b/src/saml2/config.py
index 9b7debcb..274e3960 100644
--- a/src/saml2/config.py
+++ b/src/saml2/config.py
@@ -69,6 +69,7 @@ COMMON_ARGS = [
"allow_unknown_attributes",
"crypto_backend",
"id_attr_name",
+ "delete_tmpfiles",
]
SP_ARGS = [
@@ -243,6 +244,7 @@ class Config(object):
self.attribute = []
self.attribute_profile = []
self.requested_attribute_name_format = NAME_FORMAT_URI
+ self.delete_tmpfiles = True
def setattr(self, context, attr, val):
if context == "":
@@ -358,6 +360,12 @@ class Config(object):
except TypeError: # Something that can't be a string
setattr(self, arg, cnf[arg])
+ if not self.delete_tmpfiles:
+ logger.warning(
+ "delete_tmpfiles is set to False; "
+ "temporary files will not be deleted."
+ )
+
if "service" in cnf:
for typ in ["aa", "idp", "sp", "pdp", "aq"]:
try: