[mod_python] questions about mod_python publisher

Volodya volodya at real.samuraj.org
Thu May 20 15:27:15 EDT 2004


On Thu, May 20, 2004 at 11:54:20AM +0100, Terry MacDonald wrote:
> If I do this in http.conf
> 
> PythonDebug on
> 
> <Location /test>
>     SetHandler mod_python
>     PythonHandler mod_python.publisher
> </Location>
> 
> If in the test directory I have a file index.py containing a function
> index() and I direct my browser to http://localhost/test  I get this:
> 
> Mod_python error: "PythonHandler mod_python.publisher"
> 
> Traceback (most recent call last):
> 
>   File "/usr/lib/python2.2/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
>     result = object(req)
> 
>   File "/usr/lib/python2.2/site-packages/mod_python/publisher.py", line 98, in handler
>     path=[path])
> 
>   File "/usr/lib/python2.2/site-packages/mod_python/apache.py", line 454, in import_module
>     f, p, d = imp.find_module(parts[i], path)
> 
> ImportError: No module named test
> 
> The publisher is treating the '/test' part of the URI as a module!
> 
> So what am I doing wrong?

I've tried the same, and everything works fine.

Portion of my httpd.conf (Apache 2.0.48):

<VirtualHost 192.168.0.201:80>
     ServerName lan.MYDOMAIN.TLD
     ServerAdmin postmaster at MYDOMAIN.TLD
     DocumentRoot /home/volodya/lan/data
     ScriptAlias /cgi-bin/ /home/volodya/lan/cgi-bin/
     <Directory /home/volodya/lan/data/>
             AllowOverride All
             Order allow,deny
             Allow from all
     </Directory>
     <Directory /home/volodya/lan/cgi-bin/>
             AllowOverride All
             Options ExecCGI
             Order allow,deny
             Allow from all
     </Directory>
     # -------------------------------------------------
     <Location /test>
                 SetHandler mod_python
                 PythonHandler mod_python.publisher
     </Location>
     # -------------------------------------------------
     ErrorLog  /home/volodya/lan/log/error-lan.log
     CustomLog /home/volodya/lan/log/access-lan.log common
 </VirtualHost>


index.py , placed into /home/volodya/lan/data/test directory:

# ------------------------------
def index(req):
    return "hello"

def func(req, name="world"):
    return "Hello, %s !" % name
# ------------------------------


http://lan.MYDOMAIN.TLD/test/
  Output: hello

http://lan.MYDOMAIN.TLD/test/func?name=Volodya
  output: Hello, Volodya !


Env: Apache 2.0.48 (prefork mpm), mod_python 3.1.3, Python 2.3.3, FreeBSD 4.9



More information about the Mod_python mailing list