[mod_python] Module importing and classes

Dominique.Holzwarth at ch.delarue.com Dominique.Holzwarth at ch.delarue.com
Thu Mar 27 12:35:27 EDT 2008


Hello everyone

I'm trying to import class definitions from different modules but getting some errors...

Lets say I have the folloing structure:

Python/
        GUI/
                webGUI.py
                Edit/
                        webEdit.py

Inside webGUI.py there's a class 'WebGUI' and inside 'webEdit.py' there's a class 'WebEdit' that inherits from 'WebGUI'.
'webEdit.py' looks like this:

webEdit.py
*****************************************************
from mod_python import apache
webGUI = apache.import_module('~/GUI/webGUI.py')
class WebEdit(webGUI.WebGUI):

    def __init__(self):
        pass
*****************************************************

When I run my application I get the followin error:

File "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\python\GUI\Edit\webEdit.py", line 3, in <module>
    class WebEdit(webGUI.WebGUI):

AttributeError: 'module' object has no attribute 'WebGUI'

If I omit the 'webGUI' in the class definition of 'WebEdit' I get an error stating that 'the global name "WebGUI" is not defined' ...

So basicly I need to know how to inherit from classes which are defined in another module (which is in another folder) under mod_python... :-)

Sorry for the recently spam, this is my first web application with mod_python & apache :-/

Greetings
Dominique




More information about the Mod_python mailing list