[Checkins] SVN: Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/ View for folder-level syndication added.
Charlie Clark
charlie at begeistert.org
Sun Oct 3 07:51:09 EDT 2010
Log message for revision 117198:
View for folder-level syndication added.
Changed:
U Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/configure.zcml
U Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/syndication.py
-=-
Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/configure.zcml
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/configure.zcml 2010-10-03 11:50:29 UTC (rev 117197)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/configure.zcml 2010-10-03 11:51:09 UTC (rev 117198)
@@ -17,5 +17,13 @@
class=".syndication.Site"
permission="cmf.ManagePortal"
/>
+
+ <browser:page
+ for="Products.CMFCore.interfaces.IFolderish"
+ layer="Products.CMFDefault.interfaces.ICMFDefaultSkin"
+ name="syndicate.html"
+ class=".syndication.Syndicate"
+ permission="cmf.ManagePortal"
+ />
</configure>
Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/syndication.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/syndication.py 2010-10-03 11:50:29 UTC (rev 117197)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/syndication.py 2010-10-03 11:51:09 UTC (rev 117198)
@@ -13,11 +13,13 @@
"""Enable or disable site syndication"""
+from zope.component import getAdapter
from zope.interface import Interface
from zope.formlib import form
from zope.schema import Choice, Int, Datetime
from zope.schema.vocabulary import SimpleVocabulary
+from Products.CMFCore.interfaces import ISyndicationInfo
from Products.CMFDefault.formlib.form import EditFormBase
from Products.CMFDefault.utils import Message as _
from Products.CMFDefault.browser.utils import memoize
@@ -32,27 +34,27 @@
])
-class ISyndication(Interface):
+class ISyndicationSchema(Interface):
"""Syndication form schema"""
-
+
period = Choice(
title=_(u"Update period"),
vocabulary=frequency_vocab,
default="daily"
)
-
+
frequency = Int(
title=_(u"Update frequency"),
description=_(u"This is a multiple of the update period. An"
u" update frequency of '3' and an update period"
u" of 'Monthly' will mean an update every three months.")
)
-
+
base = Datetime(
title=_(u"Update base"),
description=_(u"")
)
-
+
max_items = Int(
title=_(u"Maximum number of items"),
description=_(u"")
@@ -61,8 +63,8 @@
class Site(EditFormBase):
"""Enable or disable syndication for a site."""
-
- form_fields = form.FormFields(ISyndication)
+
+ form_fields = form.FormFields(ISyndicationSchema)
actions = form.Actions(
form.Action(
name="enable",
@@ -83,20 +85,20 @@
success="handle_disable"
)
)
-
+
@property
@memoize
def syndtool(self):
return self._getTool("portal_syndication")
-
+
@memoize
def enabled(self, action=None):
return self.syndtool.isAllowed
-
+
@memoize
def disabled(self, action=None):
return not self.syndtool.isAllowed
-
+
def setUpWidgets(self, ignore_request=False):
data = {'frequency':self.syndtool.syUpdateFrequency,
'period':self.syndtool.syUpdatePeriod,
@@ -106,13 +108,13 @@
self.widgets = form.setUpDataWidgets(self.form_fields, self.prefix,
self.context, self.request,data=data,
ignore_request=ignore_request)
-
+
def handle_enable(self, action, data):
self.handle_update(action, data)
self.syndtool.isAllowed = 1
self.status = _(u"Syndication enabled")
self._setRedirect("portal_actions", "global/syndication")
-
+
def handle_update(self, action, data):
self.syndtool.editProperties(updatePeriod=data['period'],
updateFrequency=data['frequency'],
@@ -121,8 +123,88 @@
)
self.status = _(u"Syndication updated")
self._setRedirect("portal_actions", "global/syndication")
-
+
def handle_disable(self, action, data):
self.syndtool.isAllowed = 0
self.status = _(u"Syndication disabled")
self._setRedirect("portal_actions", "global/syndication")
+
+
+class Syndicate(EditFormBase):
+ """
+ Enable, disable and customise syndication settings for a folder
+ """
+
+ form_fields = form.FormFields(ISyndicationSchema)
+
+ actions = form.Actions(
+ form.Action(
+ name="enable",
+ label=_(u"Enable syndication"),
+ condition="disabled",
+ success="handle_enable",
+ ),
+ form.Action(
+ name="update",
+ label=_(u"Update syndication"),
+ condition="enabled",
+ success="handle_update",
+ ),
+ 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",
+ validator="validation_disabled"
+ )
+ )
+
+ @property
+ @memoize
+ def adapter(self):
+ return getAdapter(self.context, ISyndicationInfo)
+
+ def setUpWidgets(self, ignore_request=False):
+ fields = self.form_fields
+ if self.disabled():
+ fields = form.FormFields()
+ self.widgets = form.setUpDataWidgets(fields, self.prefix,
+ self.context, self.request,
+ data=self.adapter.get_info(),
+ ignore_request=ignore_request)
+
+ def enabled(self, action=None):
+ return self.adapter.enabled
+
+ def disabled(self, action=None):
+ return not self.adapter.enabled
+
+ def validation_disabled(self, action, data):
+ """Do nothing, data is irrelevant"""
+ pass
+
+ def handle_enable(self, action, data):
+ self.adapter.enable()
+ self.status = _(u"Syndication enabled for ")
+ self._setRedirect("portal_actions", "folder/syndication")
+
+ def handle_disable(self, action, data):
+ self.adapter.disable()
+ self.status = _(u"Syndication disabled for")
+ self._setRedirect("portal_actions", "folder/syndication")
+
+ def handle_update(self, action, data):
+ self.adapter.set_info(**data)
+ self.status = _(u"Syndication updated for")
+ self._setRedirect("portal_actions", "folder/syndication")
+
+ def handle_revert(self, action, data):
+ self.adapter.revert()
+ self.status = _(u"Syndication reset to site default")
+ self._setRedirect("portal_actions", "folder/syndication")
\ No newline at end of file
More information about the checkins
mailing list