[Zope] Inheritance (?) problem
Luca Manini
manini@flashnet.it
Sat, 4 May 2002 18:32:17 +0200
>>>>> "Dieter" == Dieter Maurer <dieter@handshake.de> writes:
> Luca Manini writes:
[...]
When overriding a superclass (base) method (foo) in a subclass
(sub), one often wants to call the inherited one. In 'pure'
(bare?) Python you can do this:
class sub (base):
def foo(self, arg):
sub.foo (self, arg)
I tried this with sub inheriting from SimpleItem.SimpleItem and
from an external 'pure python' class and it does not work.
> This is an ExtensionClass/Python incompatibility, documented
> with ExtensionClass. You need "inheritedAttribute" to work
> around the problem, documented too.
> Dieter
As always, Dieter (thanks) solved the problem! .
1) documented means (I think) read
..../zope/lib/python/StructuredText/regressions/ExtensionClass.stx
funny place for that piece of really interesting info.
2) You need inheritedAttribute means (I do that way and it works):
class sub (base):
def foo(self, arg):
sub.inheritedAttribute ('foo') (self, arg)
Any other trick like this in constructing (product's) Zope
classes from 'pure-python' ones?
I do prefere to have as much python code as possible out of
Zope (so that it can be use without Zope), and overriding
inherited methods is (I think) a very basic tool in this.
bye, Luca