Commit ec64a204 authored by 's avatar

Fixed finding of base classes again :)

parent 86cc67d4
...@@ -102,6 +102,21 @@ manage_addZClassForm=Globals.HTMLFile( ...@@ -102,6 +102,21 @@ manage_addZClassForm=Globals.HTMLFile(
'addZClass', globals(), default_class_='OFS.SimpleItem Item', 'addZClass', globals(), default_class_='OFS.SimpleItem Item',
CreateFactory=1) CreateFactory=1)
def find_class(ob, name):
# Walk up the aq hierarchy, looking for a ZClass
# with the given name.
while 1:
if hasattr(ob, name):
return getattr(ob, name)
elif hasattr(ob, '_getOb'):
try: return ob._getOb(name)
except: pass
if hasattr(ob, 'aq_parent'):
ob=ob.aq_parent
continue
raise AttributeError, name
def manage_addZClass(self, id, title='', baseclasses=[], def manage_addZClass(self, id, title='', baseclasses=[],
meta_type='', CreateFactory=0, REQUEST=None): meta_type='', CreateFactory=0, REQUEST=None):
"""Add a Z Class """Add a Z Class
...@@ -110,13 +125,9 @@ def manage_addZClass(self, id, title='', baseclasses=[], ...@@ -110,13 +125,9 @@ def manage_addZClass(self, id, title='', baseclasses=[],
for b in baseclasses: for b in baseclasses:
if Products.meta_classes.has_key(b): if Products.meta_classes.has_key(b):
bases.append(Products.meta_classes[b]) bases.append(Products.meta_classes[b])
elif hasattr(self, b):
bases.append(getattr(self, b))
else: else:
# If self is the "methods" propertysheet base=find_class(self, b)
# of a ZClass, get the class from the bases.append(base)
# propertysheet.
bases.append(self._getOb(b))
Z=ZClass(id,title,bases) Z=ZClass(id,title,bases)
......
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