[mod_python] super doesn't seem to always work with import

Abraham Schneider abes at cns.nyu.edu
Mon Jun 7 14:58:56 EDT 2004


Hi. I'm currently using the latest version of mod_python (3.1.3) 
w/Apache 2.x on a debian box (I compiled the sources, as the stable 
branch). I've run across a problem, which I think is due to modpython 
(and if not, figure out what in python I'm doing wrong), and I'm hoping 
someone might have some insight into how to fix it.

I have a base class 'base_object' which inherits object. My class 
hierarchy includes several levels of abstraction and sometimes also 
involves multiple inheritence. Because of this I use:

super(classname, self).__init__(*args, **kwargs)

to initialize all my classes. I will (seemingly randomly) get a type 
error (that obj is an instance of classname, and not parentclass, where 
the error is reported for invocation of the super in the parent class) 
if a class is in a different module than the parent class. I can easily 
get rid of this error by simply moving the child class into the same module.

Another way to get around this problem is to use the:

parentclass.__init__(self, *args, **kwargs)

form, but only if I do: 'from moduleX import parentclass' (so I don't 
use the form 'moduleX.parentclass.__init__' -- otherwise I'll get a 
similiar error as above).

Some extra details: I'm using the default handler (i.e. 'SetHandler 
mod_python'), and using 'apache.import_modules' to load all of my modules.

Thanks!

Abe



More information about the Mod_python mailing list