[Checkins] SVN: Products.CMFCore/trunk/Products/CMFCore/ Merge branches/2.2 at 110533: "Actions and TypeInformation: Clear the compiled *_expr_object property when the *_expr property is cleared."
Ross Patterson
me at rpatterson.net
Tue Apr 6 20:02:31 EDT 2010
Log message for revision 110575:
Merge branches/2.2 at 110533: "Actions and TypeInformation: Clear the compiled *_expr_object property when the *_expr property is cleared."
Changed:
U Products.CMFCore/trunk/Products/CMFCore/ActionInformation.py
U Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt
U Products.CMFCore/trunk/Products/CMFCore/TypesTool.py
U Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionInformation.py
U Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py
-=-
Modified: Products.CMFCore/trunk/Products/CMFCore/ActionInformation.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/ActionInformation.py 2010-04-06 17:22:22 UTC (rev 110574)
+++ Products.CMFCore/trunk/Products/CMFCore/ActionInformation.py 2010-04-07 00:02:30 UTC (rev 110575)
@@ -120,8 +120,12 @@
if isinstance(value, list):
value = tuple(value)
setattr(self, id, value)
- if value and id.endswith('_expr'):
- setattr( self, '%s_object' % id, Expression(value) )
+ if id.endswith('_expr'):
+ attr = '%s_object' % id
+ if value:
+ setattr(self, attr, Expression(value))
+ elif hasattr(self, attr):
+ delattr(self, attr)
security.declarePrivate('getInfoData')
def getInfoData(self):
Modified: Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt 2010-04-06 17:22:22 UTC (rev 110574)
+++ Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt 2010-04-07 00:02:30 UTC (rev 110575)
@@ -7,6 +7,9 @@
- Added a permissions.zcml file defining our own permissions. This was
formerly done in Zope 2's Products.Five.
+- Actions and TypeInformation: Clear the compiled *_expr_object
+ property when the *_expr property is cleared.
+
- Changed GenericSetup import handlers to fail silently if they
are called in a context that does not contain the items they
import.
Modified: Products.CMFCore/trunk/Products/CMFCore/TypesTool.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/TypesTool.py 2010-04-06 17:22:22 UTC (rev 110574)
+++ Products.CMFCore/trunk/Products/CMFCore/TypesTool.py 2010-04-07 00:02:30 UTC (rev 110575)
@@ -408,8 +408,12 @@
if isinstance(value, list):
value = tuple(value)
setattr(self, id, value)
- if value and id.endswith('_expr'):
- setattr(self, '%s_object' % id, Expression(value))
+ if id.endswith('_expr'):
+ attr = '%s_object' % id
+ if value:
+ setattr(self, attr, Expression(value))
+ elif hasattr(self, attr):
+ delattr(self, attr)
def _checkAvailable(self, ec):
""" Check if the action is available in the current context.
Modified: Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionInformation.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionInformation.py 2010-04-06 17:22:22 UTC (rev 110574)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionInformation.py 2010-04-07 00:02:30 UTC (rev 110575)
@@ -118,6 +118,29 @@
self.failUnless('value=" Add "' in form_html)
+ def test_clearExprObjects(self):
+ """When a *_expr property is set, a *_expr_object attribute is
+ also set which should also be cleared when the *_expr is
+ cleared."""
+ a = self._makeOne('foo',
+ title='Foo Title',
+ description='Foo description.',
+ url_expr='string:${object_url}/foo_url',
+ icon_expr='string:foo_icon',
+ available_expr='',
+ permissions=('View',),
+ visible=False,
+ link_target='_top')
+ self.failUnless(hasattr(a, 'icon_expr_object'))
+ self.failUnless(hasattr(a, 'url_expr_object'))
+ self.failIf(hasattr(a, 'available_expr_object'))
+ a.manage_changeProperties(
+ icon_expr='', url_expr='', available_expr='')
+ self.failIf(hasattr(a, 'icon_expr_object'))
+ self.failIf(hasattr(a, 'url_expr_object'))
+ self.failIf(hasattr(a, 'available_expr_object'))
+
+
class DummyRequest:
def __init__(self):
self._data = {}
Modified: Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py 2010-04-06 17:22:22 UTC (rev 110574)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py 2010-04-07 00:02:30 UTC (rev 110575)
@@ -471,7 +471,36 @@
self.assertEqual(ti._actions[1].action.text, wanted_actions_text1)
self.assertEqual(ti._actions[2].action.text, wanted_actions_text2)
+ def test_clearExprObjects(self):
+ """When a *_expr property is set, a *_expr_object attribute is
+ also set which should also be cleared when the *_expr is
+ cleared."""
+ ti_data = {'id': 'foo',
+ 'title': 'Foo',
+ 'description': 'Foo objects are just used for testing.',
+ 'content_meta_type': 'Foo Content',
+ 'factory': 'cmf.foo',
+ 'icon_expr': 'string:${portal_url}/foo_icon_expr.gif',
+ 'add_view_expr': 'string:${folder_url}/foo_add_view',
+ 'link_target': '_new'}
+ ti = self._makeOne(**ti_data)
+ info_data = ti.getInfoData()
+ self.failUnless(hasattr(ti, 'icon_expr_object'))
+ self.failUnless(info_data[0].get('icon'))
+ self.failUnless('icon' in info_data[1])
+ self.failUnless(hasattr(ti, 'add_view_expr_object'))
+ self.failUnless(info_data[0].get('url'))
+ self.failUnless('url' in info_data[1])
+ ti.manage_changeProperties(icon_expr='', add_view_expr='')
+ info_data = ti.getInfoData()
+ self.failIf(hasattr(ti, 'icon_expr_object'))
+ self.failIf(info_data[0].get('icon'))
+ self.failIf('icon' in info_data[1])
+ self.failIf(hasattr(ti, 'add_view_expr_object'))
+ self.failIf(info_data[0].get('url'))
+ self.failIf('url' in info_data[1])
+
class FTIDataTests( TypeInfoTests, unittest.TestCase ):
def _getTargetClass(self):
More information about the checkins
mailing list