[mod_python] Reloading modified scripts

Patrick Percot ppercot at free.fr
Fri Jun 11 18:29:09 EDT 2004

On Tue, 01 Jun 2004 10:25:47 +0200 (CEST), Patrick Percot <ppercot at free.fr> wrote

> Bonjour,
> Despite  the presence  of "PythonAutoReload  On" in  my  httpd.conf, the
> modified  files are  not handled  correctly.  I  need to  restart Apache
> server to ensure that modified code is executed. 

I apologize for  the multipost if this mail arrives twice  (I sent it 24
hours ago, but it is not yet returned back to me). 

First of all : Thanks, Elan for your help. 

I  found a  better solution,  maybe you  can try  it and  tell me  if it
works for you. 

It appears that some directives, such as those :

		PythonDebug On
		PythonAutoReload On
		PythonOption Hello World

have to appear included in this directive :

	<Files *>
		PythonPath "sys.path + ['/var/www/lhassa/web2'] + ['/var/www/lhassa']"
		PythonDebug On
		PythonAutoReload On
		PythonOption Hello World

to be really activated.

Demonstration with this uggly small piece of code :

        ret = "<br/>Config :<br/>"
        conf = self._req.get_config()
        for key in conf.keys() :
            ret = ret + "Cnf : " + key + " = " + conf[key] + "<br/>"
        ret = ret + "<br/>Options :<br/>"
        options = self._req.get_options()
        for key in options.keys() :
            ret = ret + "Opt : " + key + " = " + options[key] + "<br/>"

that returns :

Config :
Cnf : PythonPath = sys.path + ['/var/www/lhassa/web2'] + ['/var/www/lhassa']
Cnf : PythonDebug = 1
Cnf : PythonAutoReload = 1

Options :
Opt : Hello = World

When those variables are included in <Files *> directive, and returns :

Config :
Cnf : PythonPath = sys.path + ['/var/www/lhassa/web2'] + ['/var/www/lhassa']

Options :

when they are not. 

Notice that my PythonPath directive was yet included in the <Files *> directive. 

Find below an extract from the documentation (the Files directive is not
mentioned) :

5.4.10 PythonOption

Syntax: PythonOption key value
Context: server config, virtual host, directory, htaccess
Override: not None
Module: mod_python.c

Assigns a key value  pair to a table that can be  later retrieved by the
req.get_options() function.  This is useful to  pass information between
the  apache configuration  files  (httpd.conf, .htaccess,  etc) and  the
Python programs.

Hope it helps.

Groupe Morbihannais d'Utilisateurs de Logiciels Libres http://www.tuxbihan.org
Identifiant Jabber: pp at amessage.de
GPG fingerprint = 1A4F E154 3D2C A20E E4CA  A543 7951 C5C2 E44A A0B5

Patrick Percot.

More information about the Mod_python mailing list