Graham Dumpleton
grahamd at dscpl.com.au
Tue Jul 18 18:24:34 EDT 2006
Richard Lewis wrote .. > On Tuesday 18 July 2006 15:56, Gregory Jones wrote: > > Hello all, > > > > I had a quick question. I come from the mod_perl world to the mod_python > > world. I am really enjoying mod_python and wanted to thank everyone who > > has put all the work into it. It is fun! Now, on to the question. I am > > curious how to set a variable inside the httpd.conf file. In mod_perl > I > > could use PerlSetVar and then call that variable inside perl. > > > > Example: > > > > PerlModule My::Module > > <Location /module> > > PerlSetVar my_variable 'variable value' ### This is what I am > > looking for > > SetHandler perl-script > > PerlHandler My::Module > > PerlSendHeader Off > > </Location> > > > I do this: > > Apache configuration includes: > > SetVar my_variable 'variable value' > > Handler script includes: > > def handler(req): > req.add_common_vars() > env_dict = req.subprocess_env > > val = env_dict['my_variable'] A mod_python specific way of doing this is to use the directive: PythonOption my_variable 'variable value' In the handler you then access it as: def handler(req): val = req.get_options()['my_variable'] You are highly encouraged to use namespace prefixes for your option names so they don't conflict with other packages (including mod_python at the moment), which have created names with effective global scope. For example: PythonOption mystuff.variable 'variable value' Graham
|