[Zope3-dev] Re: keeping attributes abstract
Marko Mikulicic
marko at autistici.org
Thu Mar 9 06:09:12 EST 2006
On 09.03.2006., at 11:43, Sam Stainsby wrote:
> On Thu, 09 Mar 2006 04:29:12 -0500, Benji York wrote:
>
>
>> class Foo(Persistent):
>> implements(IFooB)
>>
>> @apply
>> def bar(self):
>> doc = """The bar attribute"""
>>
>> def fset(self, bar):
>> if bar is None:
>> self._bar = 47
>> else:
>> self._bar = bar
>>
>> def fget(self):
>> return self._bar * 44
>>
>> return property(**locals)
>
> Ah, good ... the situation is better than I thought, although the
> code is
> a little complex than I would like to see. How would you go about
> overriding the accessor or mutator in a subclass?
class Foo(Persistent):
implements(IFooB)
def setBar(self, bar):
....
def getBar(self):
....
bar = property(getBar, setBar)
of course a subclasser of Foo needs to know that he is subclassing a
Foo and not simply a IFooB, however this is mostly a documentation issue
More information about the Zope3-dev
mailing list