[CMF-checkins] SVN: CMF/branches/2.1/C - CMFDefault.PropertiesTool:
Fix a faulty manage_changeProperties
Jens Vagelpohl
jens at dataflake.org
Sun Dec 30 06:31:08 EST 2007
Log message for revision 82567:
- CMFDefault.PropertiesTool: Fix a faulty manage_changeProperties
invocation which broke the 'Reconfigure Portal' screen
(https://bugs.launchpad.net/zope-cmf/+bug/174246)
Changed:
U CMF/branches/2.1/CHANGES.txt
U CMF/branches/2.1/CMFDefault/PropertiesTool.py
U CMF/branches/2.1/CMFDefault/tests/test_PropertiesTool.py
-=-
Modified: CMF/branches/2.1/CHANGES.txt
===================================================================
--- CMF/branches/2.1/CHANGES.txt 2007-12-30 04:10:03 UTC (rev 82566)
+++ CMF/branches/2.1/CHANGES.txt 2007-12-30 11:31:06 UTC (rev 82567)
@@ -1,3 +1,12 @@
+CMF 2.1.1 (unreleased)
+
+ Bug Fixes
+
+ - CMFDefault.PropertiesTool: Fix a faulty manage_changeProperties
+ invocation which broke the 'Reconfigure Portal' screen
+ (https://bugs.launchpad.net/zope-cmf/+bug/174246)
+
+
CMF 2.1.1-beta (2007/12/29)
Bug Fixes
Modified: CMF/branches/2.1/CMFDefault/PropertiesTool.py
===================================================================
--- CMF/branches/2.1/CMFDefault/PropertiesTool.py 2007-12-30 04:10:03 UTC (rev 82566)
+++ CMF/branches/2.1/CMFDefault/PropertiesTool.py 2007-12-30 11:31:06 UTC (rev 82567)
@@ -63,7 +63,7 @@
def editProperties(self, props):
'''Change portal settings'''
site = getUtility(ISiteRoot)
- site.manage_changeProperties(props)
+ site.manage_changeProperties(**props)
getUtility(IMailHost).smtp_host = props['smtp_server']
if hasattr(self, 'propertysheets'):
ps = self.propertysheets
Modified: CMF/branches/2.1/CMFDefault/tests/test_PropertiesTool.py
===================================================================
--- CMF/branches/2.1/CMFDefault/tests/test_PropertiesTool.py 2007-12-30 04:10:03 UTC (rev 82566)
+++ CMF/branches/2.1/CMFDefault/tests/test_PropertiesTool.py 2007-12-30 11:31:06 UTC (rev 82567)
@@ -18,9 +18,57 @@
import unittest
import Testing
+from zope.component import getSiteManager
+from zope.component import getUtility
+from zope.testing.cleanup import cleanUp
-class PropertiesToolTests(unittest.TestCase):
+from OFS.PropertyManager import PropertyManager
+from Products.MailHost.interfaces import IMailHost
+from Products.MailHost.MailHost import MailHost
+
+from Products.CMFCore.interfaces import IPropertiesTool
+from Products.CMFCore.interfaces import ISiteRoot
+from Products.CMFCore.tests.base.dummy import DummySite
+from Products.CMFCore.tests.base.testcase import SecurityTest
+
+class PropertiedDummySite(PropertyManager, DummySite):
+ _properties = (
+ {'id':'title', 'type':'string', 'mode': 'w'},
+ {'id':'description', 'type':'text', 'mode': 'w'},
+ {'id':'email_from_address', 'type':'string', 'mode': 'w'},
+ {'id':'email_from_name', 'type':'string', 'mode': 'w'},
+ {'id':'validate_email', 'type':'boolean', 'mode': 'w'},
+ {'id':'default_charset', 'type':'string', 'mode': 'w'},
+ {'id':'email_charset', 'type':'string', 'mode': 'w'},
+ {'id':'enable_permalink', 'type':'boolean', 'mode': 'w'},
+ )
+ title = description = email_from_address = email_from_name = ''
+ default_charset = email_charset = ''
+ validate_email = enable_permalink = False
+
+
+class PropertiesToolTests(SecurityTest):
+
+ def _makeOne(self, *args, **kw):
+ from Products.CMFDefault.PropertiesTool import PropertiesTool
+
+ return PropertiesTool(*args, **kw)
+
+ def setUp(self):
+ SecurityTest.setUp(self)
+ self.site = PropertiedDummySite('site')
+ sm = getSiteManager()
+ sm.registerUtility(self.site, ISiteRoot)
+ self.site._setObject('portal_properties', self._makeOne())
+ sm.registerUtility(self.site.portal_properties, IPropertiesTool)
+ self.site._setObject('MailHost', MailHost('MailHost'))
+ sm.registerUtility(self.site.MailHost, IMailHost)
+
+ def tearDown(self):
+ cleanUp()
+ SecurityTest.tearDown(self)
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from Products.CMFCore.interfaces.portal_properties \
@@ -36,7 +84,35 @@
verifyClass(IPropertiesTool, PropertiesTool)
+ def test_editProperties(self):
+ # https://bugs.launchpad.net/zope-cmf/+bug/174246
+ # PropertiesTool.editProperties fails with traceback due to
+ # faulty invocation of the site's manage_changeProperties method
+ props = { 'email_from_name' : 'Test Admin'
+ , 'email_from_address' : 'test at example.com'
+ , 'description' : 'Test MailHost Description'
+ , 'title' : 'Test MailHost'
+ , 'smtp_server' : 'mail.example.com'
+ , 'validate_email' : True
+ , 'email_charset' : 'iso-8859-15'
+ , 'default_charset' : 'iso-8859-1'
+ , 'enable_permalink' : True
+ }
+ tool = getUtility(IPropertiesTool)
+ tool.editProperties(props)
+ site_prop = self.site.getProperty
+ self.assertEquals(getUtility(IMailHost).smtp_host, 'mail.example.com')
+ self.assertEquals(site_prop('email_from_name'), 'Test Admin')
+ self.assertEquals(site_prop('email_from_address'), 'test at example.com')
+ self.assertEquals(site_prop('description'), 'Test MailHost Description')
+ self.assertEquals(site_prop('title'), 'Test MailHost')
+ self.assertEquals(site_prop('validate_email'), True)
+ self.assertEquals(site_prop('email_charset'), 'iso-8859-15')
+ self.assertEquals(site_prop('default_charset'), 'iso-8859-1')
+ self.assertEquals(site_prop('enable_permalink'), True)
+
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(PropertiesToolTests),
More information about the CMF-checkins
mailing list