[Zope] Attribute lookup
Gabriel Genellina
gagenellina at softlab.com.ar
Fri Oct 31 13:24:46 EST 2003
Hello
I have a class A, and another class B which is a wrapper for it (a Product,
inherited from SimpleItem.SimpleItem). I want B to delegate most attributes
to A:
class A:
def __init__(self, title, ...):
self.title = title
....
class B(SimpleItem.SimpleItem):
def __init__(self, id, title):
self.id = id
self.innerA = A(title)
def __getattr__(self, name):
return getattr(self.__dict__['innerA'], name)
This works fine for most attributes *but* title. SimpleItem.Item has a
class attribute 'title' and, altough B instances have no 'title' attribute
at all, they inherit an empty class attribute 'title' from Item, and never
goes thru __getattr__.
How could I arrange things so 'title' comes from inner A instance, and
*not* from Item base class?
Gabriel Genellina
Softlab SRL
More information about the Zope
mailing list