Commit fcc06546 authored by Nicolas Dumazet's avatar Nicolas Dumazet

update DocumentationHelper-related code and tests after move

to ZODB property sheets


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43151 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 57aa2029
...@@ -550,7 +550,6 @@ def initializePortalTypeDynamicWorkflowMethods(ptype_klass, portal_workflow): ...@@ -550,7 +550,6 @@ def initializePortalTypeDynamicWorkflowMethods(ptype_klass, portal_workflow):
dc_workflow_dict = dict() dc_workflow_dict = dict()
interaction_workflow_dict = dict() interaction_workflow_dict = dict()
for wf in portal_workflow.getWorkflowsFor(portal_type): for wf in portal_workflow.getWorkflowsFor(portal_type):
wf_id = wf.id wf_id = wf.id
wf_type = wf.__class__.__name__ wf_type = wf.__class__.__name__
...@@ -3421,7 +3420,7 @@ class Base( CopyContainer, ...@@ -3421,7 +3420,7 @@ class Base( CopyContainer,
dynamic_accessor_list = [] # Accessors dynamic_accessor_list = [] # Accessors
found_accessors = {} # Accessor names : filled by PortalType-level found_accessors = {} # Accessor names : filled by PortalType-level
# scan, and used in PropertySheet-level scan. # scan, and used in PropertySheet-level scan.
dochelper = newTempDocumentationHelper(self.getParentValue(), self.getId(), dochelper = newTempDocumentationHelper(self, self.getId(),
title=item_id, type=item_class.__name__, title=item_id, type=item_class.__name__,
description=inspect.getdoc(documented_item), description=inspect.getdoc(documented_item),
) )
...@@ -3439,9 +3438,22 @@ class Base( CopyContainer, ...@@ -3439,9 +3438,22 @@ class Base( CopyContainer,
for k, v in item_class.__dict__.items(): for k, v in item_class.__dict__.items():
if k in excluded_property_set: if k in excluded_property_set:
continue continue
if k.startswith('_base') or k.startswith('_category'):
continue
subdochelper = newTempDocumentationHelper(dochelper, k, subdochelper = newTempDocumentationHelper(dochelper, k,
title=k, description=inspect.getdoc(v), title=k, description=inspect.getdoc(v),
security=repr(getattr(documented_item, '%s__roles__' % (k,),None))) security=repr(getattr(documented_item, '%s__roles__' % (k,),None)))
if callable(v):
try:
my_type = v.__class__.__name__
subdochelper.setType(my_type)
except AttributeError:
pass
if 'Setter' not in my_type and \
'Getter' not in my_type and \
'Tester' not in my_type: # Accessors are handled separatelly.
dynamic_method_list.append(subdochelper)
try: try:
subdochelper.setType(v.__class__.__name__) subdochelper.setType(v.__class__.__name__)
except AttributeError: except AttributeError:
...@@ -3468,22 +3480,6 @@ class Base( CopyContainer, ...@@ -3468,22 +3480,6 @@ class Base( CopyContainer,
# PortalType-level methods # PortalType-level methods
# XXX: accessing portal_type directly because accessors are not generated on instances # XXX: accessing portal_type directly because accessors are not generated on instances
if getattr(documented_item, 'portal_type', None) is not None:
aq_key = documented_item._aq_key()
for k, v in Base.aq_portal_type[aq_key].__dict__.items():
if callable(v) and not (k.startswith('_base') or k.startswith('_category')):
subdochelper = newTempDocumentationHelper(dochelper, k,
title=k, description=inspect.getdoc(v),
security=repr(getattr(documented_item, '%s__roles__' % (k,),None)))
try:
my_type = v.__class__.__name__
subdochelper.setType(my_type)
except AttributeError:
pass
if 'Setter' not in my_type and \
'Getter' not in my_type and \
'Tester' not in my_type: # Accessors are handled separatelly.
dynamic_method_list.append(subdochelper)
# KEEPME: usefull to track the differences between accessors defined on # KEEPME: usefull to track the differences between accessors defined on
# PortalType and the one detected on the documented item. # PortalType and the one detected on the documented item.
# else: # else:
...@@ -3823,12 +3819,9 @@ class TempBase(Base): ...@@ -3823,12 +3819,9 @@ class TempBase(Base):
InitializeClass(TempBase) InitializeClass(TempBase)
def newTempDocumentationHelper(folder, id, REQUEST=None, **kw): def newTempDocumentationHelper(folder, id, REQUEST=None, **kw):
o = TempDocumentationHelper(id) type_tool = folder.getPortalObject().portal_types
o = o.__of__(folder) type_info = getattr(type_tool, 'Documentation Helper')
if kw is not None: return type_info.constructTempInstance(folder, id, **kw)
o._edit(force_update=1, **kw)
return o
class DocumentationHelper(Base): class DocumentationHelper(Base):
""" """
......
...@@ -1101,14 +1101,13 @@ def initialize( context ): ...@@ -1101,14 +1101,13 @@ def initialize( context ):
XXX: this code is (almost) duplicated from ERP5Types/Base.py:asDocumentationHelper XXX: this code is (almost) duplicated from ERP5Types/Base.py:asDocumentationHelper
""" """
from Products.ERP5Type import document_class_registry import erp5.portal_type
from Products.ERP5Type.dynamic.portal_type_class import _importClass
# XXX so this is ugly, but should disappear with classes in ZODB # XXX so this is ugly, but should disappear with classes in ZODB
my_class = _importClass(document_class_registry[class_id]) my_class = getattr(erp5.portal_type, class_id)
method_list = [] method_list = []
property_list = [] property_list = []
dochelper = newTempDocumentationHelper(self.getPortalObject(), class_id, title=class_id, dochelper = newTempDocumentationHelper(self, self.getId(), title=class_id,
type=my_class.__class__.__name__, type=my_class.__class__.__name__,
description=inspect.getdoc(my_class)) description=inspect.getdoc(my_class))
try: try:
......
...@@ -124,24 +124,18 @@ class TestClassTool(ERP5TypeTestCase): ...@@ -124,24 +124,18 @@ class TestClassTool(ERP5TypeTestCase):
This tests checks that Documentation Helper works with propertysheets This tests checks that Documentation Helper works with propertysheets
that define their categories using expressions. that define their categories using expressions.
""" """
from Products.ERP5Type import PropertySheet from Products.ERP5Type.Core import DynamicCategoryProperty
from Products.ERP5Type.Document.Movement import Movement from erp5.portal_type import Movement, Delivery
from Products.ERP5Type.Document.Delivery import Delivery
from Products.CMFCore.Expression import Expression
movement = Movement('dummy_movement').__of__( movement = Movement('dummy_movement').__of__(
Delivery('dummy_delivery').__of__(self.portal)) Delivery('dummy_delivery').__of__(self.portal))
# This test relies on the fact that Movement class has categories defined # This test relies on the fact that Movement class has categories defined
# by an expression. # by an expression.
found_one = 0 portal_property_sheets = self.portal.portal_property_sheets
for ps in movement.property_sheets: movement_propert_sheet = portal_property_sheets.Movement
if isinstance(ps, basestring):
ps = getattr(PropertySheet, ps) for ps in movement_propert_sheet.contentValues():
for category in getattr(ps, '_categories', []): if isinstance(ps, DynamicCategoryProperty.DynamicCategoryProperty):
if isinstance(category, Expression):
found_one = 1
break break
if found_one:
break
else: else:
self.fail("Movement _categories doesn't include expressions; " self.fail("Movement _categories doesn't include expressions; "
"this test is outdated") "this test is outdated")
......
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