[Erp5-report] r12064 - /erp5/trunk/products/ERP5Type/ERP5Type.py

nobody at svn.erp5.org nobody at svn.erp5.org
Sat Jan 13 16:38:32 CET 2007


Author: jp
Date: Sat Jan 13 16:38:31 2007
New Revision: 12064

URL: http://svn.erp5.org?rev=12064&view=rev
Log:
Add a permission property so that it is easier to control which kind of portal types can be created in which context.

Modified:
    erp5/trunk/products/ERP5Type/ERP5Type.py

Modified: erp5/trunk/products/ERP5Type/ERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/ERP5Type.py?rev=12064&r1=12063&r2=12064&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/ERP5Type.py (original)
+++ erp5/trunk/products/ERP5Type/ERP5Type.py Sat Jan 13 16:38:31 2007
@@ -35,6 +35,7 @@
 from Products.CMFCore.utils import SimpleItemWithProperties
 from Products.CMFCore.Expression import createExprContext
 from Products.CMFCore.exceptions import AccessControl_Unauthorized
+from Products.CMFCore.utils import _checkPermission
 from Products.ERP5Type import PropertySheet
 from Products.ERP5Type import _dtmldir
 from Products.ERP5Type import Permissions
@@ -91,6 +92,8 @@
     _properties = (TypeInformation._basic_properties + (
         {'id':'factory', 'type': 'string', 'mode':'w',
          'label':'Product factory method'},
+        {'id':'permission', 'type': 'string', 'mode':'w',
+         'label':'Add permission'},
         {'id':'init_script', 'type': 'string', 'mode':'w',
          'label':'Init Script'},
         {'id':'acquire_local_roles'
@@ -141,6 +144,7 @@
     hidden_content_type_list = ()
     filter_actions = 0
     allowed_action_list = []
+    permission = ''
 
     # Groups are used to classify portal types (e.g. resource).
     defined_group_list = (
@@ -170,6 +174,17 @@
     #
     #   Agent methods
     #
+    security.declarePublic('isConstructionAllowed')
+    def isConstructionAllowed( self, container ):
+        """
+        Does the current user have the permission required in
+        order to construct an instance?
+        """
+        permission = self.permission
+        if permission and not _checkPermission( permission, container ):
+            return 0
+        return FactoryTypeInformation.isConstructionAllowed(self, container)
+
     def _getFactoryMethod(self, container, check_security=1):
         if not self.product or not self.factory:
             raise ValueError, ('Product factory for %s was undefined' %




More information about the Erp5-report mailing list