[Checkins] SVN: Products.CMFDefault/trunk/Products/CMFDefault/ Simplified view code through inheritance and added disable and enable methods to the SyndicationTool to make it orthogonal to SyndicationInfos
Charlie Clark
cvs-admin at zope.org
Tue Sep 4 11:35:49 UTC 2012
Log message for revision 127686:
Simplified view code through inheritance and added disable and enable methods to the SyndicationTool to make it orthogonal to SyndicationInfos
Changed:
U Products.CMFDefault/trunk/Products/CMFDefault/SyndicationTool.py
U Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/syndication.py
U Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/tests/test_syndication.py
U Products.CMFDefault/trunk/Products/CMFDefault/tests/test_SyndicationTool.py
-=-
Modified: Products.CMFDefault/trunk/Products/CMFDefault/SyndicationTool.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/SyndicationTool.py 2012-09-04 11:34:34 UTC (rev 127685)
+++ Products.CMFDefault/trunk/Products/CMFDefault/SyndicationTool.py 2012-09-04 11:35:45 UTC (rev 127686)
@@ -108,6 +108,12 @@
info.base = updateBase or self.base
info.max_items = max_items or self.max_items
+ def enable(self):
+ self.enabled = True
+
+ def disable(self):
+ self.enabled = False
+
security.declareProtected(ManageProperties, 'enableSyndication')
def enableSyndication(self, obj):
"""
Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/syndication.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/syndication.py 2012-09-04 11:34:34 UTC (rev 127685)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/syndication.py 2012-09-04 11:35:45 UTC (rev 127686)
@@ -53,6 +53,8 @@
)
)
+ redirect = ("portal_actions", "global/syndication")
+
@memoize
def getContent(self):
syndtool = getUtility(ISyndicationTool)
@@ -67,91 +69,50 @@
return not self.getContent().enabled
def handle_enable(self, action, data):
- self.getContent().enabled = True
+ self.getContent().enable()
self._handle_success(action, data)
self.status = _(u"Syndication enabled.")
- self._setRedirect("portal_actions", "global/syndication")
+ self._setRedirect(*self.redirect)
def handle_change(self, action, data):
self._handle_success(action, data)
self.status = _(u"Syndication settings changed.")
- self._setRedirect("portal_actions", "global/syndication")
+ self._setRedirect(*self.redirect)
def handle_disable(self, action, data):
- self.getContent().enabled = False
+ self.getContent().disable()
self.status = _(u"Syndication disabled.")
- self._setRedirect("portal_actions", "global/syndication")
+ self._setRedirect(*self.redirect)
-class Folder(SettingsEditFormBase):
+class Folder(Site):
"""Enable, disable and customise syndication settings for a folder.
"""
- template = ViewPageTemplateFile("syndication.pt")
- form_fields = form.FormFields(ISyndicationInfo).omit('enabled')
label = _(u"Configure Folder Syndication")
- actions = form.Actions(
+ actions = Site.actions
+ actions.append(
form.Action(
- name="enable",
- label=_(u"Enable Syndication"),
- condition="disabled",
- success="handle_enable",
- ),
- form.Action(
- name="change",
- label=_(u"Change"),
- condition="enabled",
- success="handle_change",
- ),
- form.Action(
- name="revert",
- label=_(u"Revert to Site Default"),
- condition="enabled",
- success="handle_revert",
- ),
- form.Action(
- name="disable",
- label=_(u"Disable Syndication"),
- condition="enabled",
- success="handle_disable",
+ name="revert",
+ label=_(u"Revert to Site Default"),
+ condition="enabled",
+ success="handle_revert",
+ )
)
- )
+ redirect = ("portal_actions", "object/syndication")
+
@memoize
def getContent(self):
return getAdapter(self.context, ISyndicationInfo)
@memoize
- def disabled(self, action=None):
- return not self.enabled()
-
- @memoize
- def enabled(self, action=None):
- return self.getContent().enabled
-
- @memoize
def allowed(self, action=None):
return self.getContent().allowed
- def handle_enable(self, action, data):
- self.getContent().enable()
- self._handle_success(action, data)
- self.status = _(u"Syndication enabled.")
- self._setRedirect("portal_actions", "object/syndication")
-
- def handle_disable(self, action, data):
- self.getContent().disable()
- self.status = _(u"Syndication disabled.")
- self._setRedirect("portal_actions", "object/syndication")
-
- def handle_change(self, action, data):
- self._handle_success(action, data)
- self.status = _(u"Syndication settings changed.")
- self._setRedirect("portal_actions", "object/syndication")
-
def handle_revert(self, action, data):
self.getContent().revert()
self.status = _(u"Syndication reset to site default.")
- self._setRedirect("portal_actions", "object/syndication")
+ self._setRedirect(*self.redirect)
Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/tests/test_syndication.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/tests/test_syndication.py 2012-09-04 11:34:34 UTC (rev 127685)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/tests/test_syndication.py 2012-09-04 11:35:45 UTC (rev 127686)
@@ -44,7 +44,13 @@
def isSiteSyndicationAllowed(self):
return self.enabled
+ def enable(self):
+ self.enabled = True
+ def disable(self):
+ self.enabled = False
+
+
class SiteSyndicationTests(unittest.TestCase):
def setUp(self):
Modified: Products.CMFDefault/trunk/Products/CMFDefault/tests/test_SyndicationTool.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/tests/test_SyndicationTool.py 2012-09-04 11:34:34 UTC (rev 127685)
+++ Products.CMFDefault/trunk/Products/CMFDefault/tests/test_SyndicationTool.py 2012-09-04 11:35:45 UTC (rev 127686)
@@ -165,7 +165,7 @@
MAX_ITEMS = 42
tool = self._makeOne()
- tool.enabled = True
+ tool.enable()
context = self._makeContext()
tool.enableSyndication(context)
@@ -201,7 +201,7 @@
tool.period = PERIOD
tool.frequency = FREQUENCY
tool.base = NOW
- tool.enabled = True
+ tool.enable()
tool.max_items = MAX_ITEMS
self.assertEqual(len(tool.getSyndicatableContent(self.app.pf)), 0)
@@ -219,7 +219,7 @@
NOW = datetime.now()
tool = self._makeOne()
- tool.enabled = True
+ tool.enable()
context = self._makeContext()
info = self._makeInfo(context)
@@ -244,7 +244,7 @@
NOW = datetime.now()
tool = self._makeOne()
- tool.enabled = True
+ tool.enable()
context = self._makeContext()
info = self._makeInfo(context)
@@ -269,7 +269,7 @@
max_items = 10
tool = self._makeOne()
- tool.enabled = True
+ tool.enable()
context = self._makeContext()
info = self._makeInfo(context)
@@ -290,7 +290,7 @@
period = 2
tool = self._makeOne()
- tool.enabled = True
+ tool.enable()
context = self._makeContext()
info = self._makeInfo(context)
@@ -311,7 +311,7 @@
frequency = 'weekly'
tool = self._makeOne()
- tool.enabled = True
+ tool.enable()
context = self._makeContext()
info = self._makeInfo(context)
More information about the checkins
mailing list