[mod_python] Mapping a URI to pages dynamically.

David Fraser davidf at sjsoft.com
Tue May 20 17:19:34 EST 2003


Dustin Mitchell wrote:

>On Tue, May 20, 2003 at 02:12:39PM +0200, David Fraser wrote:
>  
>
>>Dustin Mitchell wrote:
>>
>>    
>>
>>>On Tue, May 20, 2003 at 09:30:22AM +0200, David Fraser wrote:
>>>
>>>
>>>      
>>>
>>>>I have found that we need to create physical directories in the Apache 
>>>>html directory corresponding to any subdirectories we want to handle in 
>>>>the Python script, otherwise we get a 404 error. Has anyone else found 
>>>>this? Is the SetLocation the answer for this?
>>>>The reason I would like to know is we would like to use dynamically 
>>>>generated path names without them existing on the disk
>>>>  
>>>>
>>>>        
>>>>
>>>For some unknown reason Apache checks that req.filename exists.  I usually
>>>just point it at the translation script itself (__file__).
>>>
>>>Dustin
>>>
>>>
>>>
>>>      
>>>
>>Thanks, where does the check happen, and where do you do the pointing?
>>Looking at the docs, I guess it could happen in PythonTransHandler, 
>>    
>>
>
>It's the transhandler's job to set req.filename, actually.  I think, if it
>doesn't get set, the Apache handler gets triggered, which gives you the 404.
>So set req.filename in your transhandler.
>
>  
>
>>PythonHeaderParserHandler or PythonInitHandler
>>It doesn't seem clear to me exactly where the path resolution is done in 
>>Apache relative to these handlers... Looking at the mod_python source 
>>didn't seem to indicate either
>>    
>>
>
>Path resolution is the stated goal of the transhandler.
>
>  
>
>>PythonTransHandler is designed to resolve the URI to a filename, but the 
>>resolution is actually correct, so it would be nice not to interfere 
>>before the actual .htaccess file is used...
>>    
>>
>
>You can't mess with .htaccess if you're going to do transhandlers.  You'll
>have to put your config in the httpd.conf file, or some derivative thereof.
>Apache's transhandler is the one that *finds* the .htaccess files.  You can't
>have it both ways -- Apache finds your .htaccess, then lets you redo the
>translation phase.
>
>Dustin
>
>  
>
Thanks Dustin, all clear now...
David



More information about the Mod_python mailing list