Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43656

Re: Python with Apache

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 <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; 'modified:': 0.05; 'subject:Python': 0.06; 'cache': 0.07; 'error:': 0.07; "'user'": 0.16; '.py': 0.16; 'arg,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'help?': 0.16; 'instance:': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject:Apache': 0.16; 'wrote:': 0.18; 'module': 0.19; 'trying': 0.19; 'import': 0.22; 'header :User-Agent:1': 0.23; 'error': 0.23; 'form:': 0.24; 'parse': 0.24; 'header:In-Reply-To:1': 0.27; 'installed': 0.27; 'function': 0.29; 'raise': 0.29; "skip:' 10": 0.31; 'cgi': 0.31; 'file': 0.32; 'skip:c 30': 0.32; '(most': 0.33; 'skip:# 10': 0.33; 'skip:_ 10': 0.34; 'skip:d 20': 0.34; 'subject:with': 0.35; 'created': 0.35; 'received:84': 0.35; 'skip:" 50': 0.36; 'entry': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'recent': 0.39; 'skip:_ 30': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'called': 0.40; 'blank': 0.60; 'location:': 0.61; 'browser': 0.61; 'happen': 0.63; 'details': 0.65; 'reply': 0.66; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'you:': 0.81; 'directory:': 0.84; 'reply-to:addr:python.org': 0.84; 'skip:/ 30': 0.84; '2013': 0.98
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=N54QSQNB c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=7AxPfEIvyrUA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=esVDcgjiECYA:10 a=OQ8q1YNnAAAA:8 a=_4wJw4hfOPHv0hdhGlcA:9 a=wPNLvfGTeEIA:10 a=iq8soUj3dw8A:10
X-AUTH mrabarnett:2500
Date Tue, 16 Apr 2013 03:38:21 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5
MIME-Version 1.0
To python-list@python.org
Subject Re: Python with Apache
References <CAHq3d9DAJt3_G3=aGVLXk5t4oLM6u6QDwG3BzdDznXDbErXRpA@mail.gmail.com>
In-Reply-To <CAHq3d9DAJt3_G3=aGVLXk5t4oLM6u6QDwG3BzdDznXDbErXRpA@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.654.1366079901.3114.python-list@python.org> (permalink)
Lines 80
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366079901 news.xs4all.nl 2652 [2001:888:2000:d::a6]:52741
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43656

Show key headers only | View raw


On 16/04/2013 03:02, Renato Barbosa Pim Pereira wrote:
> 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('<title>Reply Page</title>')        # html reply page
> if not 'user' in form:
>      print('<h1>Who are you?</h1>')
> else:
>      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/sites-available/default:
>
>      DocumentRoot /var/www
>      <Directory /var/www/py/>
>              AddHandler mod_python .py
>              PythonHandler cgi101
>              PythonDebug On
>          </Directory>
>
> 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
> }
>
I think it's looking for a function called 'handler' in the module 
'cgi101.py'.

This might help you:

http://www.modpython.org/live/mod_python-2.7.8/doc-html/tut-overview.html

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Python with Apache MRAB <python@mrabarnett.plus.com> - 2013-04-16 03:38 +0100

csiph-web