--- Ian L <[EMAIL PROTECTED]> wrote:
> i've got a psp page with about 4 lines of code on it, which isnt
> working.
>
> I've imported cgi, and i have the following lines of code:
> <%
> form = cgi.FieldStorage()
> formname = form["name"].value
> %>
> some html
> <%=formname%>
>
> when i submit the form to this page, i get the error:
> fileitem = form["name"].value File
> "/usr/local/lib/python2.1/cgi.py", line
> 550, in __getitem__ raise KeyError,
> key KeyError: name
>
> But i KNOW there is a form field called name. In fact in the
> debug info
> under the HTTPRequest field. I'm guessing instead of using
> cgi.FieldStorage
> i have to access the HTTPRequest class in some way. Can anyone
> point me to
> some sample code that shows me the correct way of doing this?
>
Use the source Luke.
Read HTTPRequest.py then inside the psp
<%
form_fields = self.request().fields()
%>
<%= form_fields['name'] %>
or better yet...
<%
request = self.request()
%>
<%= request.field('name') %>
Using the request allows you to access forms and cookies from the
same object. You can also get the session, transaction,
environment and other request attributes.
--Karl
--Karl
__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss