[mod_python] Re: [modwsgi] loading configuration

Graham Dumpleton graham.dumpleton at gmail.com
Mon Jul 14 06:37:51 EDT 2008


2008/7/14 bharath venkatesh <bharathv6.project at gmail.com>:
> hi everyone,
>                     I want to load certain configuration from a
> configuration file  when a appache starts in mod python or mod wsgi  using a
> function take for example load_config() .. i don't want to include this
> load_config function inside handler as i don't want it to  execute every
> time.. and  also  when ever changes are made in the configuration file i
> should be able to load the changed configuration with out restarting appache
> ... can any one tell me how this can be done ...

For both mod_python or mod_wsgi, you don't have to have it inside the
handler/application function, you can instead stick it at global scope
within the same code file and the code will be executed when the
module/file is first loaded. By default the file is loaded on first
request which targets the application. For mod_python you can force it
to load at process startup using PythonImport directive. For mod_wsgi
you can use WSGIImportScript directive. In mod_wsgi 3.0 you will also
through options to WSGIScriptAlias where you define application mount
point be able to set things so code is preloaded on process startup.

For mod_wsgi, information on reloading and how to can cause automatic
reload of application/configuration without restarting whole of
Apache, see:

  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode

In mod_python, you could use its code reloading ability, but your
configuration file would then have to be valid Python code and
couldn't be some other file format.

Graham


More information about the Mod_python mailing list