Alex Greif
alex.greif at gmail.com
Wed Aug 9 05:53:34 EDT 2006
the apache._server.get_config() works fine Thanks, Alex. On 8/9/06, Graham Dumpleton <grahamd at dscpl.com.au> wrote: > > On 09/08/2006, at 5:28 PM, Alex Greif wrote: > > > Hi, > > in the docs I only find req.get_options() > > > > But I need access to the options before the first request. > > Is there a similar method in the apache object? Unfortunately I did > > not find one > > > > <Directory ...> > > SetHandler mod_python > > PythonHandler mod_python.publisher > > PythonOption key "value" <---- this one > > </Directory> > > > > The workaround I use now is to start apache with a -D and then call > > apache.exists_config_define() > > But for my needs this is a smelling workaround :(( > > > > So a apache.get_options() would be the best because the options are > > global anyway, so I dont understand why access to them is only > > possible through the request object > > When you use req.get_options() the result is the combination of all > options > from global scope, through VirtualHost, Directory/Location/Files > and .htaccess > files which are relevant to the target of the request. > > Thus req.get_options() would already return the specific PythonOption > your > mail points at when executed from within a handler. > > There is also req.connection.base_server.get_options() which equates to > the combination of options down to VirtualHost level. This will not > contain > any overrides for specific options inside of Directory/Location/Files > directives > or .htaccess file relevant to the specific request. > > In mod_python 3.2.10, there is also req.server.get_options(). This is > similar to req.get_options(), but returns only the options defined at > global > scope within the Apache configuration. That is, outside of the > context of > any VirtualHost, Location, Directory or Files directives. > > In mod_python 3.3, one will also be able to access the main server > object > through apache.main_server. Thus apache.main_server.get_options() will > return the same as req.server.get_options() except that since it is > in the apache > module it can be used at global scope within modules at the time they > are > being imported. > > The apache.main_server object in mod_python 3.3 did exist in mod_python > 3.2.10, but was called apache._server and wasn't officially part of > the public > API at that point. > > Thus apache.main_server may be what you want if you mean to be able to > access it outside of any handler (before a request arrives), but your > PythonOption > must be at global scope, not within the Directory directive as you > have it. > > Graham >
|