[Checkins] SVN: Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/ Format and whitespace cleanup.
Charlie Clark
charlie at begeistert.org
Wed Sep 29 17:33:18 EDT 2010
Log message for revision 117073:
Format and whitespace cleanup.
Changed:
U Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/configure.zcml
U Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/syndication.py
U Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/tests/test_syndication.py
-=-
Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/configure.zcml
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/configure.zcml 2010-09-29 21:23:01 UTC (rev 117072)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/configure.zcml 2010-09-29 21:33:17 UTC (rev 117073)
@@ -2,20 +2,20 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">
- <browser:page
- for="Products.CMFCore.interfaces.ISiteRoot"
- layer="Products.CMFDefault.interfaces.ICMFDefaultSkin"
- name="configure.html"
- class=".config.PortalConfig"
- permission="cmf.ManagePortal"
+ <browser:page
+ for="Products.CMFCore.interfaces.ISiteRoot"
+ layer="Products.CMFDefault.interfaces.ICMFDefaultSkin"
+ name="configure.html"
+ class=".config.PortalConfig"
+ permission="cmf.ManagePortal"
/>
-
- <browser:page
- for="Products.CMFCore.interfaces.ISiteRoot"
- layer="Products.CMFDefault.interfaces.ICMFDefaultSkin"
- name="syndication.html"
- class=".syndication.Manage"
- permission="cmf.ManagePortal"
- />
+ <browser:page
+ for="Products.CMFCore.interfaces.ISiteRoot"
+ layer="Products.CMFDefault.interfaces.ICMFDefaultSkin"
+ name="syndication.html"
+ class=".syndication.Manage"
+ permission="cmf.ManagePortal"
+ />
+
</configure>
Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/syndication.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/syndication.py 2010-09-29 21:23:01 UTC (rev 117072)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/syndication.py 2010-09-29 21:33:17 UTC (rev 117073)
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2008 Zope Foundation and Contributors.
+# Copyright (c) 2010 Zope Foundation and Contributors.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
@@ -10,11 +10,9 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+
"""Enable or disable site syndication"""
-import logging
-LOG = logging.getLogger("Syndication settings")
-
from zope.interface import Interface
from zope.formlib import form
from zope.schema import Choice, Int, Datetime
@@ -26,42 +24,42 @@
frequency_vocab = SimpleVocabulary.fromItems(
- [
- (_(u'Hourly'), 'hourly'),
+ [(_(u'Hourly'), 'hourly'),
(_(u'Daily'), 'daily'),
(_(u'Weekly'), 'weekly'),
(_(u'Monthly'), 'monthly'),
- (_(u'Yearly'), 'yearly',)
- ]
- )
+ (_(u'Yearly'), 'yearly')
+ ])
class ISyndication(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 update frequency of '3' and an update period of 'Monthly' will mean an update every 3 three months.")
- )
+ 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"")
)
class Manage(EditFormBase):
-
+
form_fields = form.FormFields(ISyndication)
actions = form.Actions(
form.Action(
@@ -83,36 +81,35 @@
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,
+ data = {'frequency':self.syndtool.syUpdateFrequency,
'period':self.syndtool.syUpdatePeriod,
'base':self.syndtool.syUpdateBase,
'max_items':self.syndtool.max_items
}
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'],
@@ -122,8 +119,8 @@
)
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")
\ No newline at end of file
+ self._setRedirect("portal_actions", "global/syndication")
Modified: Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/tests/test_syndication.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/tests/test_syndication.py 2010-09-29 21:23:01 UTC (rev 117072)
+++ Products.CMFDefault/trunk/Products/CMFDefault/browser/admin/tests/test_syndication.py 2010-09-29 21:33:17 UTC (rev 117073)
@@ -22,13 +22,13 @@
class DummySyndicationTool(object):
-
+
isAllowed = 0
updatePeriod = "daily"
updateFrequency = 1
updateBase = ""
max_items = 15
-
+
def editProperties(self, **kw):
for k, v in kw.items():
setattr(self, k, v)
@@ -41,12 +41,12 @@
class DummyRequest(TestRequest):
-
-
+
+
def __init__(self, **kw):
super(DummyRequest, self).__init__(kw)
self.RESPONSE = DummyResponse()
-
+
def getPreferredCharsets(self):
return ['utf-8']
@@ -60,21 +60,21 @@
site._setObject('portal_actions', DummyTool())
site._setObject('portal_url', DummyTool())
site._setObject('portal_membership', DummyTool())
-
+
def _getTargetClass(self):
from Products.CMFDefault.browser.admin.syndication import Manage
request = DummyRequest(ACTUAL_URL="http://example.com")
alsoProvides(request, IUserPreferredCharsets)
return Manage(self.site, request)
-
+
def test_enabled(self):
view = self._getTargetClass()
self.assertFalse(view.enabled())
-
+
def test_disabled(self):
view = self._getTargetClass()
self.assertTrue(view.disabled())
-
+
def test_handle_enable(self):
view = self._getTargetClass()
data = {'frequency':3, 'period':'weekly', 'base':'', 'max_items':10}
@@ -98,7 +98,7 @@
self.assertTrue(view.syndtool.max_items == 10)
self.assertTrue(view.status == u"Syndication updated")
self.assertTrue(view.request.RESPONSE.location == "http://www.foobar.com/bar/site?portal_status_message=Syndication%20updated")
-
+
def test_handle_disable(self):
view = self._getTargetClass()
view.syndtool.isAllowed = True
@@ -111,4 +111,4 @@
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(SyndicationViewTests))
- return suite
\ No newline at end of file
+ return suite
More information about the checkins
mailing list