[mod_python] Udate python modules without restarting Apache

berry groenendijk berry.groenendijk at gmail.com
Fri Oct 8 00:50:54 EDT 2004


My handler is servlet.py. The excellent module build by Daniel
Popowich. I do not place this servlet.py in the mod_python
installation directory, but I have the servlet.py in the root of my
website. In a .htaccess file I have the following entries:

PythonAutoReload On
SetHandler mod_python
PythonHandler servlet
PythonDebug on

I think the problem is in the servlet.py. Because, as soon as I touch
this file I get this error:

ValueError: index is not a subclass of Servlet (in E:/Program
Files/Apache Group/Apache2/htdocs/MySite/index.mps)

Before I touched servlet.py the index file loaded perfectly.
Apparently apache tried reloading the servlet file effectively
creating a new Servlet object in memory. Other pages that have already
created in memory and that are subclasses from Servlet have now
apparently lost their 'parent'.

Any suggestions how to solve this?

Thanks,
Berry

On Fri, 8 Oct 2004 07:30:11 +1000, Graham Dumpleton
<grahamd at dscpl.com.au> wrote:
> 
> On Friday, October 8, 2004, at 07:09  AM, berry groenendijk wrote:
> 
> > There is indeed very little information on the Internet about the
> > apache.import_module funtion. I did find this Wiki page:
> > http://modpython.coedit.net/ReloadingModules
> >
> > I now import all my Python modules using apache.import_module, except
> > for all the Standard Library imports. All indirectly imported modules
> > are also imported with apache.import_module. In my .htaccess file I
> > have set PythonAutoReload On.
> >
> > But, when I make a change in a module, save it and refresh my browser,
> > the module is NOT reloaded. Why? Has anyone succefully used
> > apache.import_module?
> 
> Is the module you change one that is directly listed in a PythonHandler
> directive, or if using mod_python.publisher, is it a module which is
> being directly loaded by mod_python.publisher?
> 
> If it isn't and it is one of your common modules which is imported by
> one falling into the above class of modules, then you still may at
> least need to touch all the top level modules which use it. This is
> because import_module() will not reload a top level module if what is
> changed is actually in a module it imports.
> 
> Ie., if a.py imports b.py using import_module() and b.py is changed, but
> then access is to a.py for the web page, neither a.py nor b.py will be
> imported. You need to touch a.py first as well. If I understand things
> correctly, it should then import a.py again, which in turn, since b.py
> was modified should see import_module() import it as well.
> 
> What content handler system are you using, publisher, psp, home grown?
> Can you describe how the modules/files relate and what is being changed?
> 
> 
> 
> --
> Graham Dumpleton (grahamd at dscpl.com.au)
> 
>


More information about the Mod_python mailing list