Python Forms?

Steve Holden sholden at holdenweb.com
Wed Oct 9 15:03:06 EDT 2002


"Nico C. Kalteis" <kalteisn at yahoo.com> wrote in message
news:ao1q28$ua0$1 at slb3.atl.mindspring.net...
> Good day!
>
> First of all, thank you to anybody who can answer me this.  I'm primarily
an
> ASP developer and have only recently had cause to tinker with Python.  So
> here is my question:
>
> Is there a way to use Python to retrieve variables that are passed to it
by
> a form without using a CGI script?  In other words, is there something
> equivalent to the ASP script:
>
> <% localvariable = request("querystring") %>
>
> Any help would be greatly appreciated...
>

Basically, if you install Mark Hammond's Win32all extensions, Python becomes
an Active Scripting language, and the "Request" and "Response" objects are
available pretty much just like they are in VBScript (though obviously you
will need to ensure that your server knows your scripts are in Python and
not in VBScript :-).

Also, you'll need to make sure not to trip up over the various abbreviated
features allowed in VBScript, such as using a function name without
parentheses and expecting the function to be called: they usually doesn't
cut it in Python, though things are getting better. So try to avoid reliance
on stuff like default fields in objects and so on. Here's a short example:

<%@ LANGUAGE="PYTHON" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<%
resp=['123','456','789']
%>
<HTML>
<HEAD>
 <TITLE>Python Computation Courtesy of Active Scripting!</TITLE>
</HEAD>

<BODY>
<%
for s in resp:
 Response.write("|%s|" % s)
%>
</BODY>
</HTML>

regards
-----------------------------------------------------------------------
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Previous .sig file retired to                    www.homeforoldsigs.com
-----------------------------------------------------------------------






More information about the Python-list mailing list