[mod_python] transhandler setup?

IR labs labs at ixopusada.com
Thu Aug 25 21:59:28 EDT 2005


Sorry, I haven't been clear. I don't want so much to handle all 
requests under a directory. I like to handle all requests in general, 
and than first analyze the url. ((If the it is a certain file (.gif, 
.jpg, .css, .js) or a certain directory, apache should handle it 
further, i.e. just serve that file. If it is just a path or a .html, I 
want a python script to check wether the directory or file indeed exist 
or not. If the index.html or other .html file doesn't exist the main.py 
should take it over.))
So I wan't this analysis be done during the transHandler phase. But how 
do I make apache run my translate.py first? where do I put my config 
lines?
PythonPath "sys.path + ['/some/path']"
PythonTransHandler translate

thx
dirk

On 25-aug-05, at 23:01, Graham Dumpleton wrote:

> If you want all requests falling under a directory to be handled by
> mod_python use SetHandler and not AddHandler. Eg.
>
>   <Directory /some/path>
>   SetHandler mod_python
>   PythonHandler main
>   </Directory>
>
> Read the documentation for further information of the difference.
>
> On 25/08/2005, at 9:21 PM, IR labs wrote:
>
>> Hi All, a mod_python newbie here.
>>
>> I am trying to set up my server using mod_python's transhandler, but 
>> I can't figure out the right configuration. I am experimenting with 
>> the most crude and basic uri translation possible: every request 
>> should be redirected to main.py. But somehow apache doesn't want to 
>> do that. Right now it still displays static pages (.html files) with 
>> images, etc etc. (where I would think req.filename = 
>> '/var/www/mod_python_test/main.py' should prevent all of that.)
>>
>> This is my setup:
>>
>> from httpd.conf :
>> -----------------------------------------
>> ...
>> <IfModule mod_python.c>
>>     AddHandler mod_python .py
>>     PythonPath "sys.path + ['/var/www/mod_python_test/']"
>>     PythonTransHandler translate
>>
>> </IfModule>
>> ...
>> -----------------------------------------
>>
>> my script
>> /var/www/mod_python_test/translate.py :
>> -----------------------------------------
>> from mod_python import apache
>>
>> def transhandler(req):
>> 	req.filename = '/var/www/mod_python_test/main.py'
>> 	return apache.OK
>> -----------------------------------------
>>
>> using
>> FreeBSD 5.2.1
>> Apache 2.0.54
>> mod_python 3.1.4
>> Python 2.3.2
>>
>>
>> Note that my main.py does work through the .htaccess in 
>> /var/www/mod_python_test/
>> -----------------------------------------
>> AddHandler mod_python .py
>> PythonHandler main
>> PythonDebug On
>> -----------------------------------------
>>
>> But it (main.py) should be called for all the url's requested (not 
>> just for /mod_python_test/whatever.py and friends.)
>> thx
>> dirk
>>
>>
>>
>>
>> -----------------------------
>> Dirk van Oosterbosch
>> de Wittenstraat 225
>> 1052 AT Amsterdam
>> the Netherlands
>>
>> http://labs.ixopusada.com
>> -----------------------------
>>
>>
>> _______________________________________________
>> Mod_python mailing list
>> Mod_python at modpython.org
>> http://mailman.modpython.org/mailman/listinfo/mod_python
>
>
>

-----------------------------
Dirk van Oosterbosch
dirk at ixopusada.com
-----------------------------




More information about the Mod_python mailing list