From be8800b57a24031725121eb0c92750876287406a Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Mon, 18 Sep 2006 17:02:36 +0000 Subject: [PATCH] subobjects of temp objects should now be temps objects git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10122 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/Base.py | 7 +++++++ product/ERP5Type/ERP5Type.py | 23 ++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py index 220fedfac3..48061ae235 100644 --- a/product/ERP5Type/Base.py +++ b/product/ERP5Type/Base.py @@ -1848,6 +1848,13 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property 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): diff --git a/product/ERP5Type/ERP5Type.py b/product/ERP5Type/ERP5Type.py index 6cd4dcada2..944fe88253 100644 --- a/product/ERP5Type/ERP5Type.py +++ b/product/ERP5Type/ERP5Type.py @@ -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 @@ class ERP5TypeInformation( FactoryTypeInformation, # # 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 @@ class ERP5TypeInformation( FactoryTypeInformation, 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 -- 2.30.9