Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix syndication settings to not write on read #1147

Merged
merged 1 commit into from
Oct 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

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