[mod_python] One question in mod_python tutorial

Jorey Bump list at joreybump.com
Thu Feb 19 08:05:44 EST 2009


The last thing the world needs is another formmail script unleashed on
the Internet by newbies. :)

Ignore that example and try something simpler, if you're merely testing
Publisher functionality.

Create a file named hello.py:

def bruce(req):
    return "Hello, Bruce!"

Now point your browser at the *function* in the module:

http://host/hello.py/bruce

Once you get that working, add more sophisticated code. Publisher will
inspect the string you return and set the Content-Type to "text/plain"
if it's plaintext and "text/html" if it looks like an HTML page:

def bruce(req):
    return "<html><body><h1>Hello, Bruce!</h1></body></html>"

Make sure this is working before you try anything more sophisticated.
Then try importing some basic modules and returning output you create
with them. Troubleshooting smtplib at this point is a waste of time, as
there are any number of reasons it can fail, including the presence of
AppArmor or SELinux.


Polo InitX wrote, at 02/19/2009 05:18 AM:
> Hi all
>     I'm newbie to mod_python and I follow the mod_python document step
> by step,
> but I can't finished the tutorial in part 3.1 "A Quick Start with the
> Publisher Handler" .
> 
> My firefox return the lots of Traceback messages with error: (13,
> 'Permission denied') in last line.
> I put the form.py file in /home/www/py directory with +x permissions
> 
> Why would got Permission denied problem?
> 
> Best regards
> 
> Following is the erros messages in apache error log file
> [Thu Feb 19 18:07:28 2009] [error] [client 192.168.0.72] PythonHandler
> mod_python.publisher: Traceback (most recent call last):, referer:
> http://www.51nnyy.com/
> [Thu Feb 19 18:07:28 2009] [error] [client 192.168.0.72] PythonHandler
> mod_python.publisher:   File
> "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 299, in
> HandlerDispatch\n    result = object(req), referer: http://www.51nnyy.com/
> [Thu Feb 19 18:07:28 2009] [error] [client 192.168.0.72] PythonHandler
> mod_python.publisher:   File
> "/usr/lib64/python2.4/site-packages/mod_python/publisher.py", line 213,
> in handler\n    published = publish_object(req, object), referer:
> http://www.51nnyy.com/
> [Thu Feb 19 18:07:28 2009] [error] [client 192.168.0.72] PythonHandler
> mod_python.publisher:   File
> "/usr/lib64/python2.4/site-packages/mod_python/publisher.py", line 412,
> in publish_object\n    return
> publish_object(req,util.apply_fs_data(object, req.form, req=req)),
> referer: http://www.51nnyy.com/
> [Thu Feb 19 18:07:28 2009] [error] [client 192.168.0.72] PythonHandler
> mod_python.publisher:   File
> "/usr/lib64/python2.4/site-packages/mod_python/util.py", line 439, in
> apply_fs_data\n    return object(**args), referer: http://www.51nnyy.com/
> [Thu Feb 19 18:07:28 2009] [error] [client 192.168.0.72] PythonHandler
> mod_python.publisher:   File "/home/www/py/form.py", line 29, in
> email\n    conn = smtplib.SMTP(SMTP_SERVER), referer: http://www.51nnyy.com/
> [Thu Feb 19 18:07:28 2009] [error] [client 192.168.0.72] PythonHandler
> mod_python.publisher:   File "/usr/lib64/python2.4/smtplib.py", line
> 244, in __init__\n    (code, msg) = self.connect(host, port), referer:
> http://www.51nnyy.com/
> [Thu Feb 19 18:07:28 2009] [error] [client 192.168.0.72] PythonHandler
> mod_python.publisher:   File "/usr/lib64/python2.4/smtplib.py", line
> 306, in connect\n    raise socket.error, msg, referer:
> http://www.51nnyy.com/
> [Thu Feb 19 18:07:28 2009] [error] [client 192.168.0.72] PythonHandler
> mod_python.publisher: error: (13, 'Permission denied'), referer:
> http://www.51nnyy.com/
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list