python with ASP

Eugene Goodrich bitbucket at isomedia.com
Thu Jan 6 02:31:05 EST 2000


On Thu, 6 Jan 2000 01:12:20 -0800, "Sameer Chowdhury"
<sameerc1 at yahoo.com> wrote:
>when I run it using PWS under win98, I get the following error:
>
>Python ActiveX Scripting Engine error '80020009'=20
>
>invalid syntax=20
>
>/pytest.asp, line 3=20
>
>> <%@ LANGUAGE =3D Python %>
>> <%
>> if REQUEST.Form("title"):
>> %>
>>  <html>
>>  <b> Got Title</b>
>>  </html>
>> <% else: %>
>>  <html>

I've seen this.  HTML between code sections appears to break up the
formatting of the code as far as the interpretter is concerned (and
thus, the syntax error for the lack of statement after the 'if',
followed by another for the 'else' without a matching 'if').  Also,
after you overcome the formatting problem, you'll have to capitalize
the Request object normally (at least on IIS 4 under NT 4, you have
to).  Finally, 'Request.Form ("title")' on my machine _always_ returns
something - an instance that acts somewhat like a list.  To test if
Request.Form ("title") really got any data, I recommend you do len ()
on it, and then subscript it to get at the values if the length
indicates there are any. :)

So this code does what you want.

<%@ LANGUAGE = Python %>
<%
if len (Request.Form("title")):
	sStr = '<b> Got Title</b>'
else:
	sStr = '''<FORM ACTION="./pytest.asp" method="POST">

<b>Title:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</b><BR>
		<input type="text" value="" size=60 name="title"><P>
		<input type=submit value="Submit">
		</form>'''
%>
<html>
<%= sStr %>
</html>

    -Eugene


import binascii; print binascii.a2b_base64 ('ZXVnZW5lQGlzb21lZGlhLmNvbQ==')



More information about the Python-list mailing list