Skip to content

Commit bf6298c

Browse files
Merge pull request #855 from REANNZ/fix/reload-inplace
Reload metadata in-place
2 parents 31cd74c + bf0a4e6 commit bf6298c

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/saml2/entity.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,11 @@ def reload_metadata(self, metadata_conf):
218218
"""
219219
logger.debug("Loading new metadata")
220220
try:
221-
new_metadata = self.config.load_metadata(metadata_conf)
221+
self.metadata.reload(metadata_conf)
222222
except Exception as ex:
223223
logger.error("Loading metadata failed", exc_info=ex)
224224
return False
225225

226-
logger.debug("Applying new metadata to main config")
227-
( self.metadata, self.sec.metadata, self.config.metadata ) = [new_metadata]*3
228-
policy = getattr(self.config, "_%s_policy" % self.entity_type, None)
229-
if policy and policy.metadata_store:
230-
logger.debug("Applying new metadata to %s policy", self.entity_type)
231-
policy.metadata_store = self.metadata
232-
233-
logger.debug("Applying new metadata source_id")
234226
self.sourceid = self.metadata.construct_source_id()
235227

236228
return True

src/saml2/mdstore.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,18 @@ def load(self, *args, **kwargs):
11101110
_md.load()
11111111
self.metadata[key] = _md
11121112

1113+
def reload(self, spec):
1114+
# Save the old set of metadata
1115+
old_metadata = self.metadata
1116+
self.metadata = {}
1117+
try:
1118+
# Reload the metadata based on the spec
1119+
self.imp(spec)
1120+
except Exception as e:
1121+
# Something went wrong, restore the previous metadata
1122+
self.metadata = old_metadata
1123+
raise e
1124+
11131125
def imp(self, spec):
11141126
# This serves as a backwards compatibility
11151127
if type(spec) is dict:

0 commit comments

Comments
 (0)