Python and ASP - foo.asp (0/1)

Eugene Goodrich bitbucket at isomedia.com
Wed Jan 5 14:03:20 EST 2000


Here's a simple ASP page in Python that dumps the contents of some
collections in the Request object.

'>>>
<%@ LANGUAGE = Python %>

<%
def HTMLTableFromCollection (oCollection, sCollectionName):
	sHTML = '<table border>\n<tr><th
colspan=2>%s</th></tr>\n%s</table>\n'
	sRowPat = '<tr><td>%s</td><td>%s</td></tr>\n'
	sBody = ''
	for sKey in oCollection:
		sBody = sBody + sRowPat % (sKey, oCollection (sKey))
	return sHTML % (sCollectionName, sBody)
%>

<%= HTMLTableFromCollection (Request.ServerVariables,
'Request.ServerVariables') %>
<%= HTMLTableFromCollection (Request.ClientCertificate,
'Request.ClientCertificate') %>
<%= HTMLTableFromCollection (Request.Cookies, 'Request.Cookies') %>
<%= HTMLTableFromCollection (Request.QueryString,
'Request.QueryString') %>
'<<<

On Wed, 05 Jan 2000 14:14:34 +0000, Alan Gauld
<alan.gauld at gssec.bt.co.uk> wrote:

>Mark Hammond wrote:
>> No - you can do Python in ASP.
>
>Care to elaborate?
>
>> Not really.  Python programs running under ASP make extensive use of the ASP
>> object model, and hence won't work outside an ASP environment.  
>
>Again, how is that done? Any Web pages you can reference?
>I don't see any ASP references on python.org
>

The ASP object model is, in my mind, just the "5 magic (COM) objects"
always available to the script.  They are used in Python ASP pages
just like in VBScript ASP pages, with a few exceptions, such as the
need for exact Capitalization in some instances and a Python-side bug
that makes setting certain values in the objects more difficult.  (One
cannot simply say "Session ('foo') = 5".  One must instead say
"Session.SetValue ('foo', 5)".  And Response.Cookies is still
resisting :(.... )

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



More information about the Python-list mailing list