[Zope3-Users] __init__ method never called?

FB fbo2 at gmx.net
Tue Sep 19 03:47:03 EDT 2006


Hi,

On Mon, Sep 18, 2006 at 03:37:28PM +0100, John Smith wrote:
> Hi everyone!
> 
> the class
> zope.app.publisher.browser.fileresource.FileResource
> inherits from BrowserView and Resource in that order.
> 
> As far as I can work out, the __init__ method in
> Resource
> (zope.app.publisher.browser.resource.Resource) is
> never called.

(Please correct me if I'm wrong, I'm not a Python guru :-) )

Whenever you inherit from two classes, only the first class'
__init__ method is called implicitely on create of a new instance.

If you want both base classes' init method to be called, do something
like this:

class MyView(BrowserView,Second):
   def __init__(self,context,request):
      BrowserView.__init__(self,context,request)
      Second.__init__(self,context,request)

Regards,

Frank


More information about the Zope3-users mailing list