[mod_python] python_init errors

Jim McDonald jimmcd at ns.sympatico.ca
Sun Mar 15 00:37:25 EDT 2009


Graham Dumpleton wrote:
> 2009/3/15 Jim McDonald <jimmcd at ns.sympatico.ca>:
>   
>> Graham Dumpleton wrote:
>>
>> 2009/3/15 Jim McDonald <jimmcd at ns.sympatico.ca>:
>>
>>
>> Graham Dumpleton wrote:
>>
>> 2009/3/15 Jim McDonald <jimmcd at ns.sympatico.ca>:
>>
>>
>> OK.
>>
>> The mod_python.publisher problem is like this:
>>
>>     Following the instructions in the mod_python manual, I created a test
>> directory under my Apache server root called 'Python' and added to
>> httpd.conf these lines:
>>
>>      <Directory "C:/Program Files/Apache Software
>> Foundation/Apache2.2/htdocs/Python/">
>>         AddHandler mod_python .py
>>         PythonHandler mptest
>>         PythonDebug On
>>     </Directory>
>>
>> Mptest.py is, of course, the test script described in the manual.
>>
>> It worked as described.
>>
>> I then proceeded to the 'Tutorial' in the manual and substituted
>> mod_python.publisher for mptest in httpd.conf. I also added the form.htm
>> page to /htdocs and form.py to the Python directory. This resulted in a 404
>> error--"The requested URL /Python/form.py/email was not found on this
>> server." Simpler scripts (like mptest.py) in the same directory fail in the
>> same way.
>>
>> No error shows up in Apache's error log.
>>
>> It's very puzzling to me that Apache is unable to find files that are
>> plainly present in the places where it says it can't find them. Any advice?
>>
>>
>> Post the contents of the form.py file.
>>
>> Also have a read of:
>>
>>   http://webpython.codepoint.net/mod_python_tutorial
>>
>> It is a better tutorial.
>>
>> Graham
>>
>>
>>
>> Form.py goes like this:
>>
>> import smtplib
>>
>> WEBMASTER = "webmaster"    #webmaster email
>> SMTP_SERVER = "SIRIUS"     # That's the name of my server.
>>                            # The rest of the code is cut-and-pasted
>>                            # out of the tutorial.
>> def email(req, name, email, comment):
>>     if not (name and email and comment):
>>         return "A required parameter is missing, \
>>                     please go back and complete the form."
>>     msg = """\
>> From: %s
>> SubjectL feedback
>> To: %s
>>
>> I have the following comment:
>>
>> %s
>>
>> Thank you,
>>
>> %s
>>
>> """ % (email, WEBMASTER, comment, name)
>>
>>     # send it out
>>     conn = smtplib.SMTP(SMTP_SERVER)
>>     conn.sendmail(email, (WEBMASTER), msg)
>>     conn.quit()
>>
>>     # provide feedback to the user
>>     s = """\
>> <html>
>>
>> Dear %s,<br>
>> Thank you for your kind comments. \n
>> We will get back to you shortly.
>>
>> </html>""" % name
>>
>>     return s
>>
>> It takes input from this web form:
>>
>>  <html>
>>       Please provide feedback below:
>>   <p>
>>   <form action="Python/form.py/email" method="POST">
>>
>>       Name:    <input type="text" name="name"><br>
>>       Email:   <input type="text" name="email"><br>
>>       Comment: <textarea name="comment" rows=4 cols=20></textarea><br>
>>       <input type="submit">
>>
>>   </form>
>>   </html>
>>
>> I hope this sheds light.
>>
>> Thanks very much for your attention to this and for your quick response.
>>
>> I'll go and have a look now at the tutorial you mentioned.
>>
>>
>> This only has a chance of working if HTML file is in too directory of
>> server. Where have you put it? If in same directory as .py file,
>> change 'action' in form to be just 'form.py/email'.
>>
>> Please use reply-all and keep followups on the list.
>>
>>
>>
>> Graham
>>
>> _______________________________________________
>> Mod_python mailing list
>> Mod_python at modpython.org
>> http://mailman.modpython.org/mailman/listinfo/mod_python
>>
>>
>>
>> It was in the root directory. I moved it to the Python directory, amended
>> the path as suggested, and ran it from there. Same result.
>>     
>
> Hmmm, is your code file really called 'Form.py' as you said. Your
> action is referencing 'form.py'. This isn't Windows, the case of names
> is important.
>
> Graham
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>
>   
Good point. No, it was actually called 'FORM.PY'

Unhappily, though, changing the reference made no difference.

I want to emphasize, though, that I have several python files in the the 
Python directory (which is the subject of the /httpd.conf /directive), 
and, as long as /mod_python.publisher/ is the handler, Apache can't see 
any of them. Even the charmingly simple /mptest.py.

/Well, hardly any of them. There's one called /index.py /that runs when 
I navigate to the Python directory and click on it. Its code looks like 
this:
          def index(req):
              return "We are in index()"

          def hello(req):
              return "We are in hello()"

The others not only refuse to run, they give a 404 error. I can't see 
what distinguishes this one from the others in that respect. Do you see 
anything special about it?

-- 
-------------- next part --------------
Skipped content of type multipart/related


More information about the Mod_python mailing list