Forwarding to the list....
NB Use Reply-All when replying to the tutor list.
Alan G.
----- Forwarded Message ----
From: Ryan <[EMAIL PROTECTED]>
To: Alan Gauld <[EMAIL PROTECTED]>
Sent: Tuesday, 11 September, 2007 5:32:33 AM
Subject: Re: [Tutor] Apache, CGI-BIN, Python
Alan Gauld wrote:
> "Ryan" <[EMAIL PROTECTED]> wrote
>
>
>> I am running a Linux box and cannot find my Apache cgi-bin to put
>> some
>> python scripts in. I know I probably have to create one but don't
>> know
>> where and how.
>>
>
> I think there are several places that you can create cgi-bin depending
> on how you configure apache. But the place I usually see it is
> directly
> under the apache root directory - ie the one that is equivalent to /
> in
> the url.
>
>
>> everything works fine except:
>>
>> form = cgi.FieldStorage()
>>
>> #This is where everything goes wrong
>> #I get error messages for either the lastname line or firstname
>>
>
> Can you tell us
> a) exactly what error messages and
> b) How you are invoking the script - where are the values
> supposed to be coming from?
>
>
>> lastname = form['lastname'].value
>> firstname =form['firstname'].value
>> message = firstname + " " + lastname
>> print reshtml % message
>>
> The HTML Doc:
>
<html>
<form action = "test1.py">
<p> Enter your first name:</p>
<input type="text" name="firstname" size="40">
<input type="text" name="lastname" size="40">
<input type = "submit">
<input type ="reset">
</form>
</html>
Error:
Mod_python error: "PythonHandler mod_python.publisher"
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/mod_python/apache.py", line 299, in
HandlerDispatch
result = object(req)
File "/usr/lib/python2.5/site-packages/mod_python/publisher.py", line 204, in
handler
module = page_cache[req]
File "/usr/lib/python2.5/site-packages/mod_python/cache.py", line 82, in
__getitem__
return self._checkitem(name)[2]
File "/usr/lib/python2.5/site-packages/mod_python/cache.py", line 124, in
_checkitem
value = self.build(key, name, opened, entry)
File "/usr/lib/python2.5/site-packages/mod_python/publisher.py", line 77, in
build
return ModuleCache.build(self, key, req, opened, entry)
File "/usr/lib/python2.5/site-packages/mod_python/cache.py", line 371, in
build
exec opened in module.__dict__
File "/var/www/python/test1.py", line 16, in
lastname = form['lastname'].value
File "cgi.py", line 567, in __getitem__
raise KeyError, key
KeyError: 'lastname'
But I can get this script to work properly:
def index(req):
return "Test succesful";
> HTH,
>
>
>
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor