[Erp5-report] r10122 - in /erp5/trunk/products/ERP5Type: Base.py ERP5Type.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Sep 18 19:02:39 CEST 2006


Author: jp
Date: Mon Sep 18 19:02:36 2006
New Revision: 10122

URL: http://svn.erp5.org?rev=10122&view=rev
Log:
subobjects of temp objects should now be temps objects

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

Modified: erp5/trunk/products/ERP5Type/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Base.py?rev=10122&r1=10121&r2=10122&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py (original)
+++ erp5/trunk/products/ERP5Type/Base.py Mon Sep 18 19:02:36 2006
@@ -1848,6 +1848,13 @@
     else:
       return context.asContext(REQUEST=REQUEST, **kw)
 
+  security.declarePublic('isTempObject')
+  def isTempObject(self):
+    """
+      Tells if an object is temporary or not
+    """
+    return self.reindexObject is self._temp_reindexObject
+
   # Workflow Related Method
   security.declarePublic('getWorkflowStateItemList')
   def getWorkflowStateItemList(self):

Modified: erp5/trunk/products/ERP5Type/ERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/ERP5Type.py?rev=10122&r1=10121&r2=10122&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/ERP5Type.py (original)
+++ erp5/trunk/products/ERP5Type/ERP5Type.py Mon Sep 18 19:02:36 2006
@@ -21,6 +21,7 @@
 ##############################################################################
 
 from Globals import InitializeClass, DTMLFile
+from exceptions import AccessControl_Unauthorized
 from AccessControl import ClassSecurityInfo, getSecurityManager
 from Acquisition import aq_base, aq_inner, aq_parent
 
@@ -176,6 +177,26 @@
     #
     #   Agent methods
     #
+    def _getFactoryMethod(self, container, check_security=1):
+        if not self.product or not self.factory:
+            raise ValueError, ('Product factory for %s was undefined' %
+                               self.getId())
+        p = container.manage_addProduct[self.product]
+        if hasattr(container, 'isTempObject') and container.isTempObject():
+          factory_name = self.factory
+          factory_name.replace('add', 'newTemp')
+          m = getattr(p, factory_name, None)g
+        else:
+          m = getattr(p, self.factory, None)
+        if m is None:
+            raise ValueError, ('Product factory for %s was invalid' %
+                               self.getId())
+        if not check_security:
+            return m
+        if getSecurityManager().validate(p, p, self.factory, m):
+            return m
+        raise AccessControl_Unauthorized( 'Cannot create %s' % self.getId() )
+    
     security.declarePublic('constructInstance')
     def constructInstance( self, container, id,
                            created_by_builder=0, *args, **kw ):
@@ -189,7 +210,7 @@
         ob = FactoryTypeInformation.constructInstance(
                                              self, container, id, *args, **kw)
 
-        # Only try to assign roles to secutiry groups if some roles are defined
+        # Only try to assign roles to security groups if some roles are defined
         # This is an optimisation to prevent defining local roles on subobjects
         # which acquire their security definition from their parent
         # The downside of this optimisation is that it is not possible to




More information about the Erp5-report mailing list