Question about the "new" module

Gabriele *darkbard* Farina darkbard at gmail.com
Fri Dec 29 07:57:34 EST 2006


Hi,

I'm using Python 2.5 to develop a simple MVC framework based on
mod_python. To load my controllers, I create new modules using the
"new" module like this:

# ....
my_module = new.module("random_name")
my_module.__file__ = module_path

exec open(module_path, "r") in my_module.__dict__

then I initialize the class defined inside the module and call a method
of this class based on the HTTP request.

All works fine but the imports. If my module contains something like
this:

import something

class MyController(Controller):
    def index(self):
        something.do_something()

when MyController.index is called an exception is raised "NoneType
object has not attribute do_something". Why does it happen ? I have to
load the module in different ways (but I'd like to force the reload
every time the module is loaded) ?

Gabriele




More information about the Python-list mailing list