From 2078a7d20745e0dc2384e0001120194f74f8e284 Mon Sep 17 00:00:00 2001 From: Nathan Van Gheem Date: Sat, 17 Aug 2013 01:21:12 -0500 Subject: [PATCH] fix syndication settings to not write on read --- .../CMFPlone/browser/syndication/settings.py | 20 +++++++++++++++---- docs/CHANGES.rst | 2 ++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Products/CMFPlone/browser/syndication/settings.py b/Products/CMFPlone/browser/syndication/settings.py index 182c6b141e..611da06016 100644 --- a/Products/CMFPlone/browser/syndication/settings.py +++ b/Products/CMFPlone/browser/syndication/settings.py @@ -17,22 +17,34 @@ class FeedSettings(object): def __init__(self, context): self.context = context - annotations = IAnnotations(context) + self.annotations = IAnnotations(context) + self.needs_saving = False - self._metadata = annotations.get(FEED_SETTINGS_KEY, None) + self._metadata = self.annotations.get(FEED_SETTINGS_KEY, None) if self._metadata is None: self._metadata = PersistentDict() - annotations[FEED_SETTINGS_KEY] = self._metadata + self.needs_saving = True registry = getUtility(IRegistry) self.site_settings = registry.forInterface(ISiteSyndicationSettings, check=False) + def _set(self): + """ + what are we doing here you might ask? + well, this causes us to write on read so only set on annotation + if we need to + """ + if self.needs_saving: + self.annotations[FEED_SETTINGS_KEY] = self._metadata + def __setattr__(self, name, value): - if name in ('context', '_metadata', 'site_settings'): + if name in ('context', '_metadata', 'site_settings', 'annotations', + 'needs_saving'): self.__dict__[name] = value else: self._metadata[name] = value + self._set() def __getattr__(self, name): default = None diff --git a/docs/CHANGES.rst b/docs/CHANGES.rst index 804869a4a8..e0933509a0 100644 --- a/docs/CHANGES.rst +++ b/docs/CHANGES.rst @@ -11,6 +11,8 @@ Changelog - Release Plone 4.3.6 to correct some version incompatibilities in 4.3.5. No upgrades to run. [esteele] +- fix syndication settings to not write on read + [vangheem] 4.3.5 (2015-05-13) ------------------