sk**@pobox.com wrote:
GabrieleI'm using Python 2.5 to develop a simple MVC framework based
Gabrieleon mod_python. To load my controllers, I create new modules
Gabrieleusing the "new" module like this:
Gabriele# ....
Gabrielemy_module = new.module("random_name")
Gabrielemy_module.__file__ = module_path
Gabrieleexec open(module_path, "r") in my_module.__dict__
Gabrielethen I initialize the class defined inside the module and call
Gabrielea method of this class based on the HTTP request.
Why use the new module? Why not call __import__() or execfile()? Details
on their use are here:
http://docs.python.org/dev/lib/built-in-funcs.html
Or why not use mod_python.apache.import_module() from mod_python
itself. It is designed as a way of users importing specific modules,
including the capability for modules to be reloaded if they have been
changed. See:
http://www.dscpl.com.au/wiki/ModPyth...oduleImporting
as well as the mod_python documentation.
Is recommended though to use mod_python 3.3 as soon as you can though
if you want the module reloading to always work. You can find
descriptions of problems with the module reloading in older versions of
mod_python at:
http://www.dscpl.com.au/wiki/ModPyth...ortingIsBroken
Note that module importer in mod_python 3.3 has been enhanced some what
over prior versions in addition to fixing problems. An important new
feature is being able to load modules based on their path with modules
with same names in different directories being properly distinguished,
something which is quite useful where modules are used in web
applications to represent pages. You may want to look at documentation
for it at:
http://www.modpython.org/live/mod_py...pi-apmeth.html
Graham