[mod_python] How to access like "http://localhost/html/test.html"under mod_python.publisher ?

Graham Dumpleton grahamd at dscpl.com.au
Fri Jul 1 00:33:08 EDT 2005


GNULife wrote ..
> Now, it return the error:
> 
> Mod_python error: "PythonHandler mod_python.publisher"
> 
> ImportError: No module named head

Sorry, my psychic powers aren't working very well today. :-)

You are going to have to provide your code, what the name of that code file
is and what URL you were using is.

> How to access like "http://localhost/html/test.html" under
> mod_python.publisher ?

You can always set up mod_python.publisher as:

  AddHandler python-program .html
  PythonHandler mod_python.publisher

Do this though and you can't have static .html files in the same
directory as mod_python.publisher expects to be handling all
.html requests.

It also doesn't work well if you expect to have multiple published
methods in the same file, whether in a flat namespace or hierarchical
by using objects. This is because the URL for the published methods
ends up actually being something like:

  http://localhost/html/test.html/method1

Ie., the ".html" extension isn't at the end of the URL.

The only other option you have is to get messy and use mod_rewrite
to remap actual ".html" URLs to mod_python.publisher style URLs on
the fly.

Other than that, you would have to look at using an alternate
extension package for mod_python that focuses more on resource
based URLs where the URL reflects the type of content being returned.
When using mod_python.publisher you almost have to use REST
style URLs, ie., no extension to stop the ".py" appearing.

Maybe you would like to explain what you are trying to achieve and
whether you are using some templating system or using handcrafted
HTML. People may then be able to suggest better alternatives.

Graham


More information about the Mod_python mailing list