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):
dc_workflow_dict = dict()
interaction_workflow_dict = dict()
for wf in portal_workflow.getWorkflowsFor(portal_type):
wf_id = wf.id
wf_type = wf.__class__.__name__
......@@ -3421,7 +3420,7 @@ class Base( CopyContainer,
dynamic_accessor_list = [] # Accessors
found_accessors = {} # Accessor names : filled by PortalType-level
# 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__,
description=inspect.getdoc(documented_item),
)
......@@ -3439,9 +3438,22 @@ class Base( CopyContainer,
for k, v in item_class.__dict__.items():
if k in excluded_property_set:
continue
if k.startswith('_base') or k.startswith('_category'):
continue
subdochelper = newTempDocumentationHelper(dochelper, k,
title=k, description=inspect.getdoc(v),
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:
subdochelper.setType(v.__class__.__name__)
except AttributeError:
......@@ -3468,22 +3480,6 @@ class Base( CopyContainer,
# PortalType-level methods
# 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
# PortalType and the one detected on the documented item.
# else:
......@@ -3823,12 +3819,9 @@ class TempBase(Base):
InitializeClass(TempBase)
def newTempDocumentationHelper(folder, id, REQUEST=None, **kw):
o = TempDocumentationHelper(id)
o = o.__of__(folder)
if kw is not None:
o._edit(force_update=1, **kw)
return o
type_tool = folder.getPortalObject().portal_types
type_info = getattr(type_tool, 'Documentation Helper')
return type_info.constructTempInstance(folder, id, **kw)
class DocumentationHelper(Base):
"""
......
......@@ -1101,14 +1101,13 @@ def initialize( context ):
XXX: this code is (almost) duplicated from ERP5Types/Base.py:asDocumentationHelper
"""
from Products.ERP5Type import document_class_registry
from Products.ERP5Type.dynamic.portal_type_class import _importClass
import erp5.portal_type
# 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 = []
property_list = []
dochelper = newTempDocumentationHelper(self.getPortalObject(), class_id, title=class_id,
dochelper = newTempDocumentationHelper(self, self.getId(), title=class_id,
type=my_class.__class__.__name__,
description=inspect.getdoc(my_class))
try:
......
......@@ -124,24 +124,18 @@ class TestClassTool(ERP5TypeTestCase):
This tests checks that Documentation Helper works with propertysheets
that define their categories using expressions.
"""
from Products.ERP5Type import PropertySheet
from Products.ERP5Type.Document.Movement import Movement
from Products.ERP5Type.Document.Delivery import Delivery
from Products.CMFCore.Expression import Expression
from Products.ERP5Type.Core import DynamicCategoryProperty
from erp5.portal_type import Movement, Delivery
movement = Movement('dummy_movement').__of__(
Delivery('dummy_delivery').__of__(self.portal))
# This test relies on the fact that Movement class has categories defined
# by an expression.
found_one = 0
for ps in movement.property_sheets:
if isinstance(ps, basestring):
ps = getattr(PropertySheet, ps)
for category in getattr(ps, '_categories', []):
if isinstance(category, Expression):
found_one = 1
portal_property_sheets = self.portal.portal_property_sheets
movement_propert_sheet = portal_property_sheets.Movement
for ps in movement_propert_sheet.contentValues():
if isinstance(ps, DynamicCategoryProperty.DynamicCategoryProperty):
break
if found_one:
break
else:
self.fail("Movement _categories doesn't include expressions; "
"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