Commit 6212a920 authored by Nicolas Dumazet's avatar Nicolas Dumazet

return the list of base categories defined on the portal type and set them

on cls._categories


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42819 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 046dd013
...@@ -225,16 +225,20 @@ class PortalTypeMetaClass(GhostBaseMetaClass): ...@@ -225,16 +225,20 @@ class PortalTypeMetaClass(GhostBaseMetaClass):
base_tuple = (ERP5BaseBroken, ) base_tuple = (ERP5BaseBroken, )
attribute_dict = {} attribute_dict = {}
interface_list = [] interface_list = []
base_category_list = []
else: else:
base_tuple, interface_list, attribute_dict = class_definition base_tuple, interface_list, base_category_list, attribute_dict = class_definition
klass.__isghost__ = False klass.__isghost__ = False
klass.__bases__ = base_tuple klass.__bases__ = base_tuple
klass.resetAcquisitionAndSecurity()
for key, value in attribute_dict.iteritems(): for key, value in attribute_dict.iteritems():
setattr(klass, key, value) setattr(klass, key, value)
klass.resetAcquisitionAndSecurity() klass._categories = base_category_list
for interface in interface_list: for interface in interface_list:
classImplements(klass, interface) classImplements(klass, interface)
finally: finally:
......
...@@ -135,6 +135,13 @@ def generatePortalTypeClass(site, portal_type_name): ...@@ -135,6 +135,13 @@ def generatePortalTypeClass(site, portal_type_name):
Base Type object holding the definition of this portal type, Base Type object holding the definition of this portal type,
and computes __bases__ and __dict__ for the class that will and computes __bases__ and __dict__ for the class that will
be created to represent this portal type be created to represent this portal type
Returns tuple with 4 items:
- base_tuple: a tuple of classes to be used as __bases__
- interface_list: list of zope interfaces the portal type implements
- base_category_list: base categories defined on the portal_type itself
(a.k.a. excluding categories from Property sheets and documents)
- attribute dictionary: any additional attributes to put on the class
""" """
# LOG("ERP5Type.dynamic", INFO, "Loading portal type " + portal_type_name) # LOG("ERP5Type.dynamic", INFO, "Loading portal type " + portal_type_name)
...@@ -155,13 +162,14 @@ def generatePortalTypeClass(site, portal_type_name): ...@@ -155,13 +162,14 @@ def generatePortalTypeClass(site, portal_type_name):
# Don't do anything else, just allow to load fully the outer # Don't do anything else, just allow to load fully the outer
# portal type class # portal type class
return ((klass,), [], {}) return ((klass,), [], [], {})
# Do not use __getitem__ (or _getOb) because portal_type may exist in a # Do not use __getitem__ (or _getOb) because portal_type may exist in a
# type provider other than Types Tool. # type provider other than Types Tool.
portal_type = getattr(site.portal_types, portal_type_name, None) portal_type = getattr(site.portal_types, portal_type_name, None)
type_class = None type_class = None
base_category_list = []
if portal_type is not None: if portal_type is not None:
# type_class has a compatibility getter that should return # type_class has a compatibility getter that should return
...@@ -178,6 +186,7 @@ def generatePortalTypeClass(site, portal_type_name): ...@@ -178,6 +186,7 @@ def generatePortalTypeClass(site, portal_type_name):
mixin_list = portal_type.getTypeMixinList() mixin_list = portal_type.getTypeMixinList()
interface_list = portal_type.getTypeInterfaceList() interface_list = portal_type.getTypeInterfaceList()
base_category_list = portal_type.getTypeBaseCategoryList()
# But if neither factory_init_method_id nor type_class are set on # But if neither factory_init_method_id nor type_class are set on
# the portal type, we have to try to guess, for compatibility. # the portal type, we have to try to guess, for compatibility.
...@@ -306,6 +315,7 @@ def generatePortalTypeClass(site, portal_type_name): ...@@ -306,6 +315,7 @@ def generatePortalTypeClass(site, portal_type_name):
return (tuple(base_class_list), return (tuple(base_class_list),
interface_class_list, interface_class_list,
base_category_list,
dict(portal_type=portal_type_name)) dict(portal_type=portal_type_name))
from lazy_class import generateLazyPortalTypeClass from lazy_class import generateLazyPortalTypeClass
......
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