LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-16-2007, 02:38 PM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
mod_python - forms not working with publisher - Connection refused


I'm trying to run the example from the mod_python website & it doesn't work. That said, I can get python scripts to work with the web, just not forms. Maybe I'm doing something wrong?

here's the code:
form.html
Code:
  <html>
      Please provide feedback below:
  <p>                           
  <form action="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>
form.py
Code:
import smtplib

WEBMASTER = "webmaster"   # webmaster e-mail
SMTP_SERVER = "localhost" # your SMTP server

def email(req, name, email, comment):

    # make sure the user provided all the parameters
    if not (name and email and comment):
        return "A required parameter is missing, \
               please go back and correct the error"

    # create the message text
    msg = """\
From: %s
Subject: 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, we
will get back to you shortly.

</html>""" % name

    return s
with this apache config:
Code:
<Directory "/local/htdocs/python"> 
   AddHandler mod_python .py
   PythonHandler mod_python.publisher
   PythonDebug On 
</Directory>
makes this error:
Code:
MOD_PYTHON ERROR

ProcessId:      6764
Interpreter:    'akane.xxxx.com'

ServerName:     'akane.xxxx.com'
DocumentRoot:   '/local/htdocs'

URI:            '/python/form.py/email'
Location:       None
Directory:      '/local/htdocs/python/'
Filename:       '/local/htdocs/python/form.py'
PathInfo:       '/email'

Phase:          'PythonHandler'
Handler:        'mod_python.publisher'

Traceback (most recent call last):

  File "/local/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/local/lib/python2.5/site-packages/mod_python/importer.py", line 1229, in _process_target
    result = _execute_target(config, req, object, arg)

  File "/local/lib/python2.5/site-packages/mod_python/importer.py", line 1128, in _execute_target
    result = object(arg)

  File "/local/lib/python2.5/site-packages/mod_python/publisher.py", line 213, in handler
    published = publish_object(req, object)

  File "/local/lib/python2.5/site-packages/mod_python/publisher.py", line 425, in publish_object
    return publish_object(req,util.apply_fs_data(object, req.form, req=req))

  File "/local/lib/python2.5/site-packages/mod_python/util.py", line 554, in apply_fs_data
    return object(**args)

  File "/local/htdocs/python/form.py", line 30, in email
    conn = smtplib.SMTP(SMTP_SERVER)

  File "/local/lib/python2.5/smtplib.py", line 244, in __init__
    (code, msg) = self.connect(host, port)

  File "/local/lib/python2.5/smtplib.py", line 310, in connect
    raise socket.error, msg

error: (111, 'Connection refused')


MODULE CACHE DETAILS

Accessed:       Tue Oct 16 12:17:36 2007
Generation:     3

_mp_441c039e42e284614105ccd2ecb3c1f7 {
  FileName:     '/local/htdocs/python/form.py'
  Instance:     1 [IMPORT]
  Generation:   4
  Modified:     Mon Oct 15 11:20:38 2007
  Imported:     Tue Oct 16 12:17:36 2007
}
any ideas?
 
Old 10-16-2007, 02:44 PM   #2
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by BrianK View Post
I'm trying to run the example...
of course, after banging my head on this for long enough to post a question, not 5 minutes later, I've found the solution. The sending mail part was the problem. Don't know why they would put that in their simple example.

Oh well.. If anyone else comes up with this same problem, just comment out the lines that start with "conn"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync ,rcp not working-Connection refused! jimmyjiang Linux - Networking 2 09-17-2008 04:34 AM
rdesktop stopped working - ERROR: connect: Connection refused donraja Linux - Software 6 02-26-2008 07:39 PM
apache2 mod_python.publisher upload problem gd2shoe Linux - Server 0 06-28-2007 10:32 PM
KMLDonkey isn't working - "Connection Refused" machron1 Suse/Novell 8 03-15-2005 04:41 PM
Wine not working. Xlib: connection to ":0.0" refused by server Xerop Linux - General 1 02-18-2004 09:37 PM


All times are GMT -5. The time now is 05:35 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration