[mod_python] get_options() in apache module

Graham Dumpleton grahamd at dscpl.com.au
Wed Aug 9 06:14:20 EDT 2006


Note though that apache._server in mod_python 3.2.10 possibly has a bug
in it, in that it may use the server object for the first virtual  
host accessed and not
the main server object. This was fixed in 3.3 as is mentioned under:

  http://issues.apache.org/jira/browse/MODPYTHON-144

If you are going to rely on this, you might consider backporting the  
patches
from mod_python 3.3.

Graham

On 09/08/2006, at 7:53 PM, Alex Greif wrote:

> 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
>>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list