Commit b5066608 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Generate accessors from properties which may be defined on the portal

type itself. This fixes testERP5eGov.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43559 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fcb3be93
......@@ -7,7 +7,8 @@ from Products.ERP5Type.Accessor.Constant import Getter as ConstantGetter
from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5Type.Base import Base as ERP5Base
from Products.ERP5Type.Base import PropertyHolder, initializePortalTypeDynamicWorkflowMethods
from Products.ERP5Type.Utils import createAllCategoryAccessors, createExpressionContext, UpperCase
from Products.ERP5Type.Utils import createAllCategoryAccessors, \
createExpressionContext, UpperCase, setDefaultProperties
from ExtensionClass import ExtensionClass, pmc_init_of
from zope.interface import classImplements
......@@ -213,6 +214,14 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
cls,
portal_type_category_list,
createExpressionContext(site, site))
# Properties defined on the portal type itself are generated in
# erp5.portal_type directly, but this is unusual case (only
# PDFTypeInformation seems to use it)
portal_type_property_list = getattr(cls, '_properties', None)
if portal_type_property_list:
setDefaultProperties(cls)
# make sure that category accessors from the portal type definition
# are generated, no matter what
# XXX this code is duplicated here, in PropertySheetTool, and in Base
......
......@@ -175,6 +175,7 @@ def generatePortalTypeClass(site, portal_type_name):
portal_type_category_list = []
attribute_dict = dict(portal_type=portal_type_name,
_properties=[],
_categories=[],
constraints=[])
......@@ -287,6 +288,20 @@ def generatePortalTypeClass(site, portal_type_name):
if property_sheet in zodb_property_sheet_name_set:
property_sheet_name_set.add(property_sheet)
# PDFTypeInformation document class, for example, defines a
# method which generates dynamically properties and this is
# heavily used by egov
update_definition_dict = getattr(portal_type,
'updatePropertySheetDefinitionDict',
None)
if update_definition_dict is not None and not \
update_definition_dict.__module__.startswith('Products.ERP5Type.ERP5Type'):
try:
update_definition_dict(attribute_dict)
except AttributeError:
pass
# XXX maybe this should be a generic hook, adding property sheets
# dynamically for a given portal type name? If done well, this
# system could perhaps help erp5_egov to get rid of aq_dynamic
......
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