Re: python_init errors

Graham Dumpleton <[email protected]>
Newsgroups gmane.comp.python.mod_python
Message-ID <[email protected]>
Did you read that other tutorial I told you to read? See:

  http://webpython.codepoint.net/mod_python_publisher_uri_traversal

The perhaps go back and work through that tutorial from start to
finish instead of the one on the main mod_python site and then see if
it makes more sense.

Graham

2009/3/16 Jim McDonald <[email protected]>:
> Graham Dumpleton wrote:
>
> 2009/3/15 Jim McDonald <[email protected]>:
>
>
> 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
>
> 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.
>
>
> 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?
>
>
> What exactly is the URL in the web browser when you access 'index.py'
> and it works?
>
> The 'index.py' file is special. The documentation explains, as it
> should about the 'index' function within a file being special.
>
> Graham
>
> _______________________________________________
> Mod_python mailing list
> [email protected]
> http://mailman.modpython.org/mailman/listinfo/mod_python
>
>
>
> This is the URL: http://sirius/Python/index.py.
>
> I have to put that right in the address bar to run it. But when I type the
> URLs of most of the other python programs--which are in the same
> directory--, I get a 404 error.
>     There's another one (also from the mod_python manual--"7.1.1
> Introduction" where the mod_python.publisher explanation begins) which looks
> like this:
>
>   """ Publisher example """
>   def say(req, what="NOTHING"):
>       return "I am saying %s" % what
>
> It works when the URL passes it an argument (like
> "http://sirius/Python/nothing.py/say?what=as little as possible."), even a
> null argument like "http://sirius/Python/nothing.py/say". But if we pass it
> no argument ("http://sirius/Python/nothing.py"), we get that 404.
>
> The documentation on Traversal (7.1.2.1) says that 404 is what we get "if an
> object in the path could not be found". So I suppose that that's what's
> happening. But what object might it be?
>
>
> --
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.