[mod_python] Module importing and classes

Dominique.Holzwarth at ch.delarue.com Dominique.Holzwarth at ch.delarue.com
Fri Mar 28 10:53:52 EDT 2008


When you mentioned the circular import I did some research learned that indeed doesn't work. So yes, the solution I'm going for is to make individual modules (files) for all my 'index(req)' functions (which implement a state-machine with some sub-state-machines) and put the class definitions in extra module files which then can be imported by the the state-machine (index()) files...

I haven't tried it yet fully but in theory it should work... If not I'll post a simple example again =)

thx

-----Original Message-----
From: Graham Dumpleton [mailto:graham.dumpleton at gmail.com]
Sent: Freitag, 28. März 2008 09:46
To: Holzwarth, Dominique (Berne Bauhaus)
Cc: mod_python at modpython.org
Subject: Re: [mod_python] Module importing and classes

There should have been a section after that in the page returned in the browser.

Anyway, the problem is that you have a circular import, you shouldn't do it as not only will you get this problem, but mod_python will reimport both modules on every request even if you haven't changed them because of how dependency management between modules works. What you need to do is create a third file which contains the:

class WebGUI:
 def __init__(self):
   attribute = 0

definition and have webEdit.py import that so as to avoid the cycle.

Graham




More information about the Mod_python mailing list