[mod_python] making mod_python.publisher handle every file request

Graham Dumpleton grahamd at dscpl.com.au
Mon Aug 1 18:12:42 EDT 2005

On 02/08/2005, at 5:12 AM, Martin P. Hellwig wrote:

> Paul Anselm Härle wrote:
>>> Use SetHandler:
>>>   <Directory  /some/dir>
>>>       SetHandler mod_python
>>>       PythonHandler YOUR-HANDLER
>>>   </Directory>
>> Is it possible to do the same thing with mod_python.publisher? because
>> my <Directory> looks like this at the moment:
>>    <Directory /var/www/asc/>
>>        Options Indexes
>>        AddHandler python-program .py
>>        PythonHandler mod_python.publisher
>>        AllowOverride FileInfo
>>        Order allow,deny
>>        Allow from all
>>    </Directory>
> I can't think of any reason why not, but have you tried it and it 
> didn't work?

Just be aware that the special interpretation of URLs that publisher
does means that there will be certain restrictions on how you could
feasibly name files.

The main one is that each component of the URL must be able to map to a
Python module name, function name, variable name etc. Therefore each
component of the URL must be a valid Python identifier name. You
therefore couldn't embed '-' in a name, or having leading numeric

You also can't have a '.' in a name except where it matches against the
initial Python module that publisher loads. This extension will be
discarded and so if you have two files with the same basename and
different extensions, they wouldn't be automatically mapped to different

Publisher also doesn't allow components to have a leading underscore,
interpreting this as access to a protected object.

What problems you are going to encounter is going to depend a bit on
what you are trying to do. Do the files you want to reference actually
exist, but you want control for returning them to be managed by a
publisher function, or are all files virtual?

There may be better options depending on what you are doing.


More information about the Mod_python mailing list