Commit 1043d806 authored by Nicolas Delaby's avatar Nicolas Delaby

Optimize code


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44635 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6ee4fdd7
......@@ -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
......
......@@ -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())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment