Commit 6dbeb193 authored by Julien Muchembled's avatar Julien Muchembled

Cleanup + rewrite of TypesTool.getTypeInfo

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/portal_types@29281 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 21b416ed
...@@ -3034,8 +3034,8 @@ class Base( CopyContainer, ...@@ -3034,8 +3034,8 @@ class Base( CopyContainer,
ERP5Security.ERP5UserFactory.ERP5User ERP5Security.ERP5UserFactory.ERP5User
""" """
def cached_getAcquireLocalRoles(portal_type): def cached_getAcquireLocalRoles(portal_type):
ti = self._getTypesTool().getTypeInfo(self) ti = self._getTypesTool().getTypeInfo(portal_type)
return getattr(ti, 'acquire_local_roles', True) return ti is None or ti.getTypeAcquireLocalRole()
cached_getAcquireLocalRoles = CachingMethod(cached_getAcquireLocalRoles, cached_getAcquireLocalRoles = CachingMethod(cached_getAcquireLocalRoles,
id='Base__getAcquireLocalRoles', id='Base__getAcquireLocalRoles',
......
...@@ -475,7 +475,7 @@ class ERP5TypeInformation(XMLObject, ...@@ -475,7 +475,7 @@ class ERP5TypeInformation(XMLObject,
def getTypeInfo(self, *args): def getTypeInfo(self, *args):
if args: if args:
return self.getParentValue().getTypeInfo(self, *args) return self.getParentValue().getTypeInfo(*args)
return XMLObject.getTypeInfo(self) return XMLObject.getTypeInfo(self)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
......
...@@ -56,7 +56,7 @@ class BaseType: ...@@ -56,7 +56,7 @@ class BaseType:
'label': 'Init Script' 'label': 'Init Script'
}, },
{ 'id': 'type_acquire_local_role' { 'id': 'type_acquire_local_role'
, 'storage_id': 'acquire_local_roles' # CMF Compatibility , 'storage_id': 'acquire_local_roles' # Compatibility
, 'type': 'boolean' , 'type': 'boolean'
, 'mode': 'w' , 'mode': 'w'
, 'label': 'Acquire Local Roles' , 'label': 'Acquire Local Roles'
......
...@@ -52,27 +52,12 @@ class TypesTool(BaseTool, CMFCore_TypesTool.TypesTool): ...@@ -52,27 +52,12 @@ class TypesTool(BaseTool, CMFCore_TypesTool.TypesTool):
return () return ()
def getTypeInfo(self, *args): def getTypeInfo(self, *args):
if not len(args): if not args:
return BaseTool.getTypeInfo(self) return BaseTool.getTypeInfo(self)
else: portal_type, = args
# The next 10 lines are taken from CMFCore if not isinstance(portal_type, basestring):
# which means that the entire file is ZPLed portal_type = aq_base(portal_type).getPortalType()
# for now return self._getOb(portal_type, None)
contentType = args[0]
#return CMFCoreTypesTool.getTypeInfo(self, contentType)
if not isinstance(contentType, basestring):
if hasattr(aq_base(contentType), 'getPortalTypeName'):
contentType = contentType.getPortalTypeName()
if contentType is None:
return None
else:
return None
#ob = getattr( self, contentType, None )
ob = self._getOb(contentType, None)
if getattr(aq_base(ob), '_isTypeInformation', 0):
return ob
else:
return None
security.declareProtected(Permissions.AddPortalContent, security.declareProtected(Permissions.AddPortalContent,
'manage_addTypeInformation') 'manage_addTypeInformation')
...@@ -80,6 +65,9 @@ class TypesTool(BaseTool, CMFCore_TypesTool.TypesTool): ...@@ -80,6 +65,9 @@ class TypesTool(BaseTool, CMFCore_TypesTool.TypesTool):
typeinfo_name=None, RESPONSE=None): typeinfo_name=None, RESPONSE=None):
""" """
Create a TypeInformation in self. Create a TypeInformation in self.
This method is mainly a copy/paste of CMF Types Tool
which means that the entire file is ZPLed for now.
""" """
if add_meta_type != 'ERP5 Type Information' or RESPONSE is not None: if add_meta_type != 'ERP5 Type Information' or RESPONSE is not None:
raise ValueError raise ValueError
......
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