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,
ERP5Security.ERP5UserFactory.ERP5User
"""
def cached_getAcquireLocalRoles(portal_type):
ti = self._getTypesTool().getTypeInfo(self)
return getattr(ti, 'acquire_local_roles', True)
ti = self._getTypesTool().getTypeInfo(portal_type)
return ti is None or ti.getTypeAcquireLocalRole()
cached_getAcquireLocalRoles = CachingMethod(cached_getAcquireLocalRoles,
id='Base__getAcquireLocalRoles',
......
......@@ -475,7 +475,7 @@ class ERP5TypeInformation(XMLObject,
def getTypeInfo(self, *args):
if args:
return self.getParentValue().getTypeInfo(self, *args)
return self.getParentValue().getTypeInfo(*args)
return XMLObject.getTypeInfo(self)
security.declareProtected(Permissions.AccessContentsInformation,
......
......@@ -56,7 +56,7 @@ class BaseType:
'label': 'Init Script'
},
{ 'id': 'type_acquire_local_role'
, 'storage_id': 'acquire_local_roles' # CMF Compatibility
, 'storage_id': 'acquire_local_roles' # Compatibility
, 'type': 'boolean'
, 'mode': 'w'
, 'label': 'Acquire Local Roles'
......
......@@ -52,27 +52,12 @@ class TypesTool(BaseTool, CMFCore_TypesTool.TypesTool):
return ()
def getTypeInfo(self, *args):
if not len(args):
if not args:
return BaseTool.getTypeInfo(self)
else:
# The next 10 lines are taken from CMFCore
# which means that the entire file is ZPLed
# for now
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
portal_type, = args
if not isinstance(portal_type, basestring):
portal_type = aq_base(portal_type).getPortalType()
return self._getOb(portal_type, None)
security.declareProtected(Permissions.AddPortalContent,
'manage_addTypeInformation')
......@@ -80,6 +65,9 @@ class TypesTool(BaseTool, CMFCore_TypesTool.TypesTool):
typeinfo_name=None, RESPONSE=None):
"""
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:
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