[Zope] Inheritance and __init__
TFE MMS JARVIS JOHN
jarvis.sd082@ex.tel.co.jp
Mon, 12 Apr 1999 16:15:30 +0900
Hi!
I'm kind of stuck:
I'm trying to write a product that is a subclass of some other class
that I wrote for something else. I'm having a problem with calling
the superclass's __init__ method from within the subclass's
__init__ method.
It works within Python but not Zope. ?
I don't have any comprehensible code to show, so here's
some test code I've been using:
The superclass:
#--supernothing.py--
class Supernothing:
def __init__(self,greeting="hello"):
self.greeting=greeting
def sayhi(self):
return self.greeting
The subclasses look something like:
A.Python only:
#--subnothing.py --
import supernothing
class Subnothing(supernothing.Supernothing):
def __init__(self,greeting="I'm here!"):
supernothing.Supernothing.__init__(self,greeting)
B.Zope:
#--nothing.py--
<Various imports, etc.>
import supernothing
class nothing(Acquisition.Implicit,
Persistent,
AccessControl.Role.RoleManager,
OFS.SimpleItem.Item,
supernothing.Supernothing):
"""Blank skeleton class.
""""
<Various manage settings, etc>
def __init__(self,id,title,greeting):
self.id=id
self.title=title
supernothing.Supernothing.__init__(self,greeting) # This is line
50
<bunch of other stuff>
def addNothing(self,id,title,REQUEST=None,greeting='I am nothing!'):
"""Add a Nothing object.
"""
obj=nothing(id,title, greeting)
self._setObject(id,obj)
<the rest...>
Version A works (in the Python interpreter, of course). Version B
gives an error(in Zope):
Traceback (innermost last):
File /usr/lib/python1.5/ZPublisher/Publish.py, line 877, in publish_module
File /usr/lib/python1.5/ZPublisher/Publish.py, line 590, in publish
(Info: /queries/pictest/manage_addNothing)
File /usr/lib/python1.5/Products/nothing/nothing.py, line 81, in
addNothing
(Object: Navigation)
File /usr/lib/python1.5/Products/nothing/nothing.py, line 50, in __init__
(Object: RoleManager)
TypeError: unbound method must be called with class instance 1st argument
Can anyone see what I am missing here?
TIA!
John Jarvis