Graham Dumpleton
grahamd at dscpl.com.au
Sat May 28 18:13:30 EDT 2005
A few comments to avoid confusion. On 29/05/2005, at 7:07 AM, Martin Lesser wrote: > Rafal Zawadzki <bluszcz at jabberpl.org> writes: > >> Fragments my configurations are: >> >> <Directory /var/www/modpython> >> AllowOverride All >> AddHandler python-program .py >> PythonHandler mptest.py #i tried also with mptest (withoout >> .py) >> PythonDebug On >> </Directory> > > Do you want to use the publisher-handler? (Makes sense)? Then put > > PythonHandler mod_python.publisher > > into your apache-config or .htaccess That isn't what his code suggested he was trying to do .... :-( > Additionally you may want to put > > MultiviewsMatch Handlers I personally recommend turning off MultiViews altogether, it just causes too many problems. If you want to specifically use of no extension or ".html" instead of ".py", would suggest you look at the Vampire glue extensions for mod_python. Vampire gives you more control over what handler is executed for what extension and thereby you can avoid altogether the chance that ".py" will work or be used thus avoiding showing in your URLS how you web application is implemented. > also in there so that URIs like > http://your.domain/path/whatever > > will in fact be handeled by > > def whatever(req): > ... Just be aware that there is more to changing to publisher than just changing the name of the handler. How the handler is implemented is different. For example the original handler would have needed to be rewritten as: def whatever(req): req.content_type = "text/plain" # missing in original req.send_http_header() req.write("Hello World!") # do not return anything or the much shorter form of: def whatever(): return "Hello World!") # content type automatically determined > in the file path.py in your htdocs-documentroot > > IIRC you have to put > > DirectoryIndex ... index.py ... > > into your global apache-conf to make the extension-less URIs work. There are long standing issues with doing this. If you have "index.py" files in multiple directories, you will suffer a reload of the module each time a URL accesses a different one. If you have subdirectories, once a subdirectory one is accessed you can no longer access the one in the parent directory as it existed. Use of the same name can also result in cross module pollution. Thus, specifying index.py as a directory index file in global Apache config is not a good idea. Until 3.2 comes out, the only alternative to doing it safely is have the index handler in each directory be a different named file and specify the DirectoryIndex directive in the .htaccess file of each directory, listing each distinct file as appropriate. Relying on handlers for index files means the handler also needs to be called index() and you couldn't call it "whatever()". With the automapping to index() method, the name of the file becomes the last part of the URL. These issues are covered in: http://issues.apache.org/jira/browse/MODPYTHON-9 http://issues.apache.org/jira/browse/MODPYTHON-10 http://issues.apache.org/jira/browse/MODPYTHON-11 For publisher at least, these problems should go away with mod_python 3.2. In the interim, you could also use Vampire whose equivalent to publisher doesn't suffer the problems. Graham
|