Skip to content

Commit

Permalink
fix syndication settings to not write on read
Browse files Browse the repository at this point in the history
  • Loading branch information
vangheem authored and gforcada committed Oct 12, 2015
1 parent ca930e5 commit e56026f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 16 additions & 4 deletions Products/CMFPlone/browser/syndication/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,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)
------------------
Expand Down

0 comments on commit e56026f

Please sign in to comment.