From 1043d806267786f09f4bd17b86456150a74441fd Mon Sep 17 00:00:00 2001 From: Nicolas Delaby <nicolas@nexedi.com> Date: Fri, 25 Mar 2011 16:23:04 +0000 Subject: [PATCH] Optimize code git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44635 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/Core/Folder.py | 10 +--------- product/ERP5Type/ERP5Type.py | 11 +++-------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/product/ERP5Type/Core/Folder.py b/product/ERP5Type/Core/Folder.py index d52e0b1c6c..cebee16d46 100644 --- a/product/ERP5Type/Core/Folder.py +++ b/product/ERP5Type/Core/Folder.py @@ -95,8 +95,6 @@ def dummyFilter(object,REQUEST=None): def dummyTestAfter(object,REQUEST=None): return [] -_MARKER = object() - class FolderMixIn(ExtensionClass.Base): """A mixin class for folder operations, add content, delete content etc. """ @@ -116,17 +114,11 @@ class FolderMixIn(ExtensionClass.Base): def newContent(self, id=None, portal_type=None, id_group=None, default=None, method=None, container=None, created_by_builder=0, activate_kw=None, is_indexable=None, temp_object=0, reindex_kw=None, - compute_local_role=_MARKER, notify_workflow=True, **kw): + compute_local_role=None, notify_workflow=True, **kw): """Creates a new content. This method is public, since TypeInformation.constructInstance will perform the security check. """ - if compute_local_role is _MARKER: - # If temp object, set to False - if temp_object: - compute_local_role = False - else: - compute_local_role = True pt = self._getTypesTool() if container is None: container = self diff --git a/product/ERP5Type/ERP5Type.py b/product/ERP5Type/ERP5Type.py index dc926cda8e..a3d6dad872 100644 --- a/product/ERP5Type/ERP5Type.py +++ b/product/ERP5Type/ERP5Type.py @@ -195,8 +195,6 @@ class LocalRoleAssignorMixIn(object): role.uid = None return role -_MARKER = object() - class ERP5TypeInformation(XMLObject, FactoryTypeInformation, LocalRoleAssignorMixIn, @@ -352,7 +350,7 @@ class ERP5TypeInformation(XMLObject, security.declarePublic('constructInstance') def constructInstance(self, container, id, created_by_builder=0, - temp_object=0, compute_local_role=_MARKER, + temp_object=0, compute_local_role=None, notify_workflow=True, *args, **kw ): """ Build a "bare" instance of the appropriate type in @@ -360,12 +358,9 @@ class ERP5TypeInformation(XMLObject, Call the init_script for the portal_type. Returns the object. """ - if compute_local_role is _MARKER: + if compute_local_role is None: # If temp object, set to False - if temp_object: - compute_local_role = False - else: - compute_local_role = True + compute_local_role = not temp_object if not temp_object and not self.isConstructionAllowed(container): raise AccessControl_Unauthorized('Cannot create %s' % self.getId()) -- 2.30.9