[Erp5-report] r28351 - in /erp5/trunk/products/ERP5Type: Accessor/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Aug 12 14:02:54 CEST 2009
Author: jerome
Date: Wed Aug 12 14:02:53 2009
New Revision: 28351
URL: http://svn.erp5.org?rev=28351&view=rev
Log:
remove some compatibility code for zope 2.7
Modified:
erp5/trunk/products/ERP5Type/Accessor/Base.py
erp5/trunk/products/ERP5Type/tests/testERP5Type.py
Modified: erp5/trunk/products/ERP5Type/Accessor/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Accessor/Base.py?rev=28351&r1=28350&r2=28351&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Accessor/Base.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Accessor/Base.py [utf8] Wed Aug 12 14:02:53 2009
@@ -95,6 +95,20 @@
modified_object_list.append(instance)
return modified_object_list
+ class __roles__:
+ @staticmethod
+ def rolesForPermissionOn(ob):
+ # we explictly call _aq_dynamic to prevent acquiering the attribute
+ # from container
+ roles = ob.im_self._aq_dynamic('%s__roles__' % ob.__name__)
+ if roles is None:
+ return rolesForPermissionOn(None, ob.im_self, ('Manager',),
+ '_Modify_portal_content_Permission')
+ else:
+ # wrap explicitly, because we used _aq_dynamic
+ return roles.__of__(ob.im_self)
+
+
from Products.CMFCore.Expression import Expression
def _evaluateTales(instance=None, value=None):
from Products.ERP5Type.Utils import createExpressionContext
@@ -158,6 +172,20 @@
psyco.bind(__call__)
+ class __roles__:
+ @staticmethod
+ def rolesForPermissionOn(ob):
+ # we explictly call _aq_dynamic to prevent acquiering the attribute
+ # from container
+ roles = ob.im_self._aq_dynamic('%s__roles__' % ob.__name__)
+ if roles is None:
+ return rolesForPermissionOn(None, ob.im_self, ('Manager',),
+ '_Access_contents_information_Permission')
+ else:
+ # wrap explicitly, because we used _aq_dynamic
+ return roles.__of__(ob.im_self)
+
+
class Tester(Method):
"""
Tests if an attribute value exists
@@ -184,35 +212,3 @@
def __call__(self, instance, *args, **kw):
return getattr(aq_base(instance), self._storage_id, None) not in self._null
-try:
- from ZODB.Transaction import Transaction
- # Zope 2.7 do not patch
-except ImportError:
- # Zope 2.8, patch
- class __roles__:
- @staticmethod
- def rolesForPermissionOn(ob):
- # we explictly call _aq_dynamic to prevent acquiering the attribute
- # from container
- roles = ob.im_self._aq_dynamic('%s__roles__' % ob.__name__)
- if roles is None:
- return rolesForPermissionOn(None, ob.im_self, ('Manager',),
- '_Modify_portal_content_Permission')
- else:
- # wrap explicitly, because we used _aq_dynamic
- return roles.__of__(ob.im_self)
- Setter.__roles__ = __roles__
-
- class __roles__:
- @staticmethod
- def rolesForPermissionOn(ob):
- # we explictly call _aq_dynamic to prevent acquiering the attribute
- # from container
- roles = ob.im_self._aq_dynamic('%s__roles__' % ob.__name__)
- if roles is None:
- return rolesForPermissionOn(None, ob.im_self, ('Manager',),
- '_Access_contents_information_Permission')
- else:
- # wrap explicitly, because we used _aq_dynamic
- return roles.__of__(ob.im_self)
- Getter.__roles__ = __roles__
Modified: erp5/trunk/products/ERP5Type/tests/testERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testERP5Type.py?rev=28351&r1=28350&r2=28351&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testERP5Type.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/testERP5Type.py [utf8] Wed Aug 12 14:02:53 2009
@@ -2304,13 +2304,6 @@
def test_DefaultSecurityOnAccessors(self):
# Test accessors are protected correctly
- try:
- from ZODB.Transaction import Transaction
- return
- # Zope 2.7 do not test
- except ImportError:
- pass
-
self._addProperty('Person',
''' { 'id': 'foo_bar',
'type': 'string',
@@ -2332,13 +2325,6 @@
self.assertFalse(guarded_hasattr(obj, 'getFooBar'))
def test_DefaultSecurityOnListAccessors(self):
- try:
- from ZODB.Transaction import Transaction
- return
- # Zope 2.7 do not test
- except ImportError:
- pass
-
# Test list accessors are protected correctly
self._addProperty('Person',
''' { 'id': 'foo_bar',
@@ -2360,12 +2346,6 @@
self.assertFalse(guarded_hasattr(obj, 'getFooBarList'))
def test_DefaultSecurityOnCategoryAccessors(self):
- try:
- from ZODB.Transaction import Transaction
- return
- # Zope 2.7 do not test
- except ImportError:
- pass
# Test category accessors are protected correctly
obj = self.getPersonModule().newContent(portal_type='Person')
self.assertTrue(guarded_hasattr(obj, 'setRegion'))
@@ -2402,13 +2382,6 @@
self.assertFalse(guarded_hasattr(obj, 'getRegionRelatedValueList'))
def test_PropertySheetSecurityOnAccessors(self):
- try:
- from ZODB.Transaction import Transaction
- return
- # Zope 2.7 do not test
- except ImportError:
- pass
-
# Test accessors are protected correctly when you specify the permission
# in the property sheet.
self._addProperty('Person',
@@ -2431,26 +2404,22 @@
self.assertFalse(guarded_hasattr(obj, 'getFooBar'))
def test_edit(self):
- # not working in 2.7 as accessor not patched
- try:
- from ZODB.Transaction import Transaction
- except ImportError:
- self._addProperty('Person',
- ''' { 'id': 'foo_bar',
- 'write_permission' : 'Set own password',
- 'read_permission' : 'Manage users',
- 'type': 'string',
- 'mode': 'w', }''')
- obj = self.getPersonModule().newContent(portal_type='Person')
- obj.edit(foo_bar="v1")
- self.assertEqual(obj.getFooBar(), "v1")
-
- obj.manage_permission('Set own password', [], 0)
- self.assertRaises(Unauthorized, obj.edit, foo_bar="v2")
- self.assertEqual(obj.getFooBar(), "v1")
-
- obj._edit(foo_bar="v3")
- self.assertEqual(obj.getFooBar(), "v3")
+ self._addProperty('Person',
+ ''' { 'id': 'foo_bar',
+ 'write_permission' : 'Set own password',
+ 'read_permission' : 'Manage users',
+ 'type': 'string',
+ 'mode': 'w', }''')
+ obj = self.getPersonModule().newContent(portal_type='Person')
+ obj.edit(foo_bar="v1")
+ self.assertEqual(obj.getFooBar(), "v1")
+
+ obj.manage_permission('Set own password', [], 0)
+ self.assertRaises(Unauthorized, obj.edit, foo_bar="v2")
+ self.assertEqual(obj.getFooBar(), "v1")
+
+ obj._edit(foo_bar="v3")
+ self.assertEqual(obj.getFooBar(), "v3")
def test_accessor_security_and_getTitle_acquisition(self):
obj = self.getOrganisationModule().newContent(portal_type='Organisation')
@@ -2623,6 +2592,7 @@
person.validate()
self.assertRaises(WorkflowException, person.validate)
+
class TestAccessControl(ERP5TypeTestCase):
# Isolate test in a dedicaced class in order not to break other tests
# when this one fails.
More information about the Erp5-report
mailing list