[Erp5-report] r20999 - in /erp5/trunk/products/ERP5Type: Accessor/ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri May 16 16:51:36 CEST 2008


Author: aurel
Date: Fri May 16 16:51:35 2008
New Revision: 20999

URL: http://svn.erp5.org?rev=20999&view=rev
Log:
make security works on accessor only on zope 2.8

Modified:
    erp5/trunk/products/ERP5Type/Accessor/Accessor.py
    erp5/trunk/products/ERP5Type/tests/testERP5Type.py

Modified: erp5/trunk/products/ERP5Type/Accessor/Accessor.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Accessor/Accessor.py?rev=20999&r1=20998&r2=20999&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Accessor/Accessor.py (original)
+++ erp5/trunk/products/ERP5Type/Accessor/Accessor.py Fri May 16 16:51:35 2008
@@ -35,10 +35,7 @@
     """
       Generic Accessor - placehold for common methods
     """
-    class __roles__:
-      @staticmethod
-      def rolesForPermissionOn(ob):
-        return getattr(ob.im_self, '%s__roles__' % ob.__name__)
+    
 
     def __getinitargs__(self):
       init = getattr(self, '__init__', None)
@@ -68,3 +65,16 @@
       # Returns a reindexing alias
       from Alias import ReindexAlias
       return ReindexAlias(id, self.__name__)
+
+try:
+    from ZODB.Transaction import Transaction
+    # Zope 2.7 do not patch
+except ImportError:
+    # Zope 2.8, patch
+    class __roles__:
+      @staticmethod
+      def rolesForPermissionOn(ob):
+        return getattr(ob.im_self, '%s__roles__' % ob.__name__)
+
+    Accessor.__roles__ = __roles__
+    

Modified: erp5/trunk/products/ERP5Type/tests/testERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testERP5Type.py?rev=20999&r1=20998&r2=20999&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testERP5Type.py (original)
+++ erp5/trunk/products/ERP5Type/tests/testERP5Type.py Fri May 16 16:51:35 2008
@@ -2097,6 +2097,13 @@
 
     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',
@@ -2118,6 +2125,13 @@
       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',
@@ -2139,6 +2153,13 @@
       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'))
@@ -2174,6 +2195,13 @@
       self.assertFalse(guarded_hasattr(obj, 'getRegionValueList'))
 
     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',




More information about the Erp5-report mailing list