Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'else:': 0.03; 'modified:': 0.05; 'subject:Python': 0.06; 'cache': 0.07; 'error:': 0.07; 'skip:/ 10': 0.09; "'user'": 0.16; '.py': 0.16; 'arg,': 0.16; 'help?': 0.16; 'instance:': 0.16; 'subject:Apache': 0.16; 'to:name:python list': 0.16; 'module': 0.19; 'trying': 0.19; 'import': 0.22; 'error': 0.23; 'form:': 0.24; 'parse': 0.24; 'installed': 0.27; 'skip:p 30': 0.29; 'raise': 0.29; 'skip:& 60': 0.30; 'message-id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; 'cgi': 0.31; 'file': 0.32; 'skip:c 30': 0.32; '(most': 0.33; 'skip:# 10': 0.33; 'skip:& 30': 0.33; 'skip:_ 10': 0.34; 'skip:d 20': 0.34; 'subject:with': 0.35; 'received:209.85': 0.35; 'created': 0.35; 'received:209.85.220': 0.35; 'received:google.com': 0.35; 'skip:" 50': 0.36; 'entry': 0.36; 'received:209': 0.37; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'skip:_ 30': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'blank': 0.60; 'skip:c 50': 0.60; 'skip:\xc2 10': 0.60; 'location:': 0.61; 'browser': 0.61; 'happen': 0.63; 'details': 0.65; 'reply': 0.66; '8bit%:100': 0.72; 'directory:': 0.84; 'skip:/ 30': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=ClRtdZraIehdsUqyaA3elf7YDt3PwETSqIzNzbJt1Jo=; b=cNnMxb4ar/gIlS6xFJ5rb7TLPek+yrFkjgn8xM6W12mbvXItXtF8k1nUqNLB3bpTWA XLLfGmr3np75vk1CChX+e0Pzbsv5aWZ80FvsRTmzuaLl5CTOSM31atxs7LbVFFQgul/Q fY/g220S4kB0VFGRiGQbLohTTy2aNFa8dYAtc477P74otMFqnf85nUE0+YV9aZCmOvyD jEyldMIR0Ls3xiYTia1YrsFPeyQ22z9c1hHJlbu2jNL3yGjn+ff59rT6wHS1pq4eWp3L t8NTNCA6086K52uo8HhxXaf20jlYZrCVnJ5pqYDGUWCwNEXeQbcTQaYh/IVvEQTfFS7B dU8Q== MIME-Version: 1.0 X-Received: by 10.52.89.229 with SMTP id br5mr173405vdb.24.1366077730420; Mon, 15 Apr 2013 19:02:10 -0700 (PDT) Date: Mon, 15 Apr 2013 23:02:10 -0300 Subject: Python with Apache From: Renato Barbosa Pim Pereira To: python list Content-Type: multipart/alternative; boundary=20cf307f3762dbb1e804da70c1a9 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 158 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366077739 news.xs4all.nl 2633 [2001:888:2000:d::a6]:47926 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43653 --20cf307f3762dbb1e804da70c1a9 Content-Type: text/plain; charset=UTF-8 I am trying to execute cgi101.py: #!/usr/bin/python import cgi form = cgi.FieldStorage() # parse form data print('Content-type: text/html\n') # hdr plus blank line print('Reply Page') # html reply page if not 'user' in form: print('

Who are you?

') else: print('

Hello %s!

' % cgi.escape(form['user'].value)) I have installed mod_python do apache2 and created one entry in /etc/apache2/sites-available/default: DocumentRoot /var/www AddHandler mod_python .py PythonHandler cgi101 PythonDebug On What. happen is: when i call this file on browser I have the following error: Can someone help? MOD_PYTHON ERROR ProcessId: 2742 Interpreter: '127.0.1.1' ServerName: '127.0.1.1' DocumentRoot: '/var/www' URI: '/py/cgi101.py' Location: None Directory: '/var/www/py/' Filename: '/var/www/py/cgi101.py' PathInfo: '' Phase: 'PythonHandler' Handler: 'cgi101' Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch default=default_handler, arg=req, silent=hlist.silent) File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1206, in _process_target object = apache.resolve_object(module, object_str, arg, silent=silent) File "/usr/lib/python2.7/dist-packages/mod_python/apache.py", line 696, in resolve_object raise AttributeError, s AttributeError: module '/var/www/py/cgi101.py' contains no 'handler' MODULE CACHE DETAILS Accessed: Mon Apr 15 22:02:42 2013 Generation: 0 _mp_63ea7b6576c7d3a5f48ef8741e8048b0 { FileName: '/var/www/py/cgi101.py' Instance: 1 [IMPORT] Generation: 1 Modified: Mon Apr 15 21:52:27 2013 Imported: Mon Apr 15 22:02:42 2013 } --20cf307f3762dbb1e804da70c1a9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I am trying to execute cgi101.py:

#!= /usr/bin/python
=C2=A0
import cgi
=C2=A0
form =3D cgi.FieldStorage()=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # parse for= m data
print('Content-type: text/html\n')=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 # hdr plus blank line
print('<title>Reply Page</title>')=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 # html reply page
if not 'user' in form:
=C2=A0=C2=A0=C2=A0 print('<h1>Who are you?</h1>')
else:
=C2=A0=C2=A0=C2=A0 print('<h1>Hello <i>%s</i>!<= ;/h1>' % cgi.escape(form['user'].value))

I have= installed mod_python do apache2 and created one entry in /etc/apache2/site= s-available/default:

=C2=A0=C2=A0=C2=A0 DocumentRoot /var/www
=C2=A0=C2=A0=C2=A0 <Dire= ctory /var/www/py/>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 AddHandler mod_python .py
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0 PythonHandler cgi101
=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 PythonDebug On
=C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 </Directory>

What. happen is: when i call this file on browser I have the following erro= r:
Can someone help?

MOD_PYTHON ERROR

ProcessId:      2742
Interpreter:    '127.0.1.1'

ServerName:     '127.0.1.1'
DocumentRoot:   '/var/www'

URI:            '/py/cgi101.py'
Location:       None
Directory:      '/var/www/py/'
Filename:       '/var/www/py/cgi101.py'
PathInfo:       ''

Phase:          'PythonHandler'
Handler:        'cgi101'

Traceback (most recent call last):

  File "/usr/lib/python2.7/dist-packages/mod_python/importer.py",=
 line 1537, in HandlerDispatch
    default=3Ddefault_handler, arg=3Dreq, silent=3Dhlist.silent)

  File "/usr/lib/python2.7/dist-packages/mod_python/importer.py",=
 line 1206, in _process_target
    object =3D apache.resolve_object(module, object_str, arg, silent=3Dsile=
nt)

  File "/usr/lib/python2.7/dist-packages/mod_python/apache.py", l=
ine 696, in resolve_object
    raise AttributeError, s

AttributeError: module '/var/www/py/cgi101.py' contains no 'han=
dler'


MODULE CACHE DETAILS

Accessed:       Mon Apr 15 22:02:42 2013
Generation:     0

_mp_63ea7b6576c7d3a5f48ef8741e8048b0 {
  FileName:     '/var/www/py/cgi101.py'
  Instance:     1 [IMPORT]
  Generation:   1
  Modified:     Mon Apr 15 21:52:27 2013
  Imported:     Mon Apr 15 22:02:42 2013
}


--20cf307f3762dbb1e804da70c1a9--