Commit 40d35a36 authored by Nicolas Dumazet's avatar Nicolas Dumazet

adapt DocumentationHelper & introspection code

The property holder is now the portal type class itself.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43154 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a7b7c799
......@@ -331,9 +331,9 @@ class PropertyHolder(object):
Invokes appropriate factory and create an accessor
"""
fake_accessor = getattr(self, id)
ptype = getattr(self, '_portal_type', None)
ptype = getattr(self, 'portal_type', None)
if ptype is None:
ptype = self.portal_type
ptype = self._portal_type
if fake_accessor is PropertyHolder.WORKFLOW_METHOD_MARKER:
# Case 1 : a workflow method only
accessor = Base._doNothing
......@@ -437,7 +437,7 @@ class PropertyHolder(object):
if y is PropertyHolder.WORKFLOW_METHOD_MARKER or x == '__ac_permissions__':
continue
if len(y) == 0:
raise ValueError("problem at %s %s" % (self._portal_type, x))
continue
if not issubclass(y[0], Accessor):
continue
elif not isinstance(y, Accessor):
......@@ -1595,7 +1595,12 @@ class Base( CopyContainer,
Content properties are filtered out in getPropertyIdList so
that rendering in ZMI is compatible with Zope standard properties
"""
return [property['id'] for property in self._erp5_properties if property['type'] == 'content']
result = set()
for parent_class in self.__class__.mro():
for property in getattr(parent_class, '_properties', []):
if property['type'] == 'content':
result.add(property['id'])
return list(result)
security.declareProtected( Permissions.View, 'getStandardPropertyIdList' )
def getStandardPropertyIdList(self):
......@@ -1603,7 +1608,12 @@ class Base( CopyContainer,
Return standard properties of the current instance.
Unlike getPropertyIdList, properties are not converted or rewritten here.
"""
return [property['id'] for property in self._erp5_properties if property['type'] != 'content']
result = set()
for parent_class in self.__class__.mro():
for property in getattr(parent_class, '_properties', []):
if property['type'] != 'content':
result.add(property['id'])
return list(result)
# Catalog Related
security.declareProtected( Permissions.View, 'getObject' )
......
......@@ -73,6 +73,7 @@ class TempObjectLibrary(object):
temp_object = container.newContent(portal_type=portal_type,
id=portal_type,
temp_object=1)
self.portal_type_dict[portal_type] = temp_object
return temp_object
......@@ -297,12 +298,7 @@ class DocumentationHelper(Implicit):
return self.view()
def _getPropertyHolder(self):
property_holder = None
key = self.getPortalType(), self.getDocumentedObject().__class__
if not(Base.aq_portal_type.has_key(key)):
self.getDocumentedObject().initializePortalTypeDynamicProperties()
property_holder = Base.aq_portal_type[key]
return property_holder
return self.getDocumentedObject().__class__
InitializeClass(DocumentationHelper)
......@@ -29,7 +29,6 @@
from AccessControl import ClassSecurityInfo
from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5Type import Permissions
from Products.ERP5Type.Base import Base
from DocumentationHelper import DocumentationHelper, TempObjectLibrary
from DocumentationSection import DocumentationSection
from PortalTypeInstanceDocumentationHelper import PortalTypeInstanceDocumentationHelper
......@@ -270,9 +269,8 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
def _getPropertyHolder(self):
portal_type = getPortalType(self.uri)
temp_object = self.getTempInstance(portal_type)
dir_temp = dir(temp_object)
return Base.aq_portal_type[(portal_type, temp_object.__class__)]
import erp5.portal_type
return getattr(erp5.portal_type, portal_type)
security.declareProtected(Permissions.AccessContentsInformation, 'getWorkflowMethodIdList')
def getWorkflowMethodIdList(self):
......@@ -300,8 +298,10 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
Return a list of tuple (id, method) for every class method
"""
portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__.__bases__[0]
return self._getPropertyHolder().getClassMethodIdList(klass, **kw)
import erp5.portal_type
klass = getattr(erp5.portal_type, portal_type)
document_class = klass.__bases__[0]
return klass.getClassMethodIdList(document_class, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getClassMethodUriList')
def getClassMethodUriList(self, inherited=0, **kw):
......@@ -310,7 +310,8 @@ class PortalTypeDocumentationHelper(DocumentationHelper):
"""
method_id_list = self.getClassMethodIdList(inherited=inherited, **kw)
portal_type = getPortalType(self.uri)
klass = self.getTempInstance(portal_type).__class__.__bases__[0]
import erp5.portal_type
klass = getattr(erp5.portal_type, portal_type)
class_name = klass.__name__
module = klass.__module__
uri_prefix = '%s.%s.' % (module, class_name)
......
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