Convert ASP Request to sequence (PythonWin)

Dirk Leas dirkl at home.com
Thu Oct 21 02:21:10 EDT 1999


Fantastic! I'm starting a Python ASP HOW-TO. I'll add this sample code if
you don't mind. Any other relevant tidbits would be helpful as well. I'd
like to walk through the entire ASP object model and show sample code on
everything (I working from the some docs at
www.chilisoft.com/caspdoc/ch05.html.

Anybody else that's interested in contributing, shoot my anything you would
like to see in such a reference. I'm also interested in things like relative
performance numbers, productivity numbers, portability with various ASP
engines on various platforms, etc.

Send me an email directly if you'd like to help with contributions or
editing/technical review.

Thanks again, Nikolai...


-----Original Message-----
From: Nikolai Kirsebom [mailto:nikolai at micon.no]
Sent: Wednesday, October 20, 1999 3:17 PM
To: python-list at python.org
Subject: Re: Convert ASP Request to sequence (PythonWin)


I don't know if I fully understand your question, but I've written a
'generic python class' which processes the Request and puts/retreives
objects in a database (all processed on ASP pages).

I use the QueryString member-method of the Request object together with
string split:

Something like:

rq = string.split(Request.QueryString(), "&")
...
for par in rq:
   token, val = string.split(par,"=")
   self.__dict__[token] = val
db = win32com.client.Dispatch("ADODB.Connection")
db.Open(self.Dsn)
rs = win32com.client.Dispatch("ADODB.Recordset")
s = "select * from %s where Id=%d" % (self.Table, self.Attr["Id"])
rs.Open(s, db, adOpenDynamic, adLockOptimistic, adCmdText)
for a in self.Attr.keys():
   rs.Fields(a).Value = self.Attr(a)
rs.Update()
rs.Close()
db.Close()
...

The method 'Attr' of course just tries to fetch the value from object's
dictionary.


Note that you probably have to make use of the urllib module on the string.

Hope this helps.

Nikolai


Dirk Leas wrote in message ...
>Thanks for the response..
>
>I tried the first approach  and got the following is the response: "This
>object does not support enumeration". In the second approach, "r" comes
back
>as None. I tested both with IIS and PWS.
>
>Where can I go to dig deeper into this?
>
>Thx,
>D
>
>-----Original Message-----
>From: Mark Hammond [mailto:mhammond at skippinet.com.au]
>Sent: Tuesday, October 19, 1999 8:51 AM
>To: 'LS, Python'
>Subject: RE: Convert ASP Request to sequence (PythonWin)
>
>
>Im not in a position to test this, but one of either:
>
>for r in Request:
>  print r
>
>i=1
>while 1:
>  try:
>    r = Request.Item(i)
>  except pythoncom.com_error:
>    break
>
>should work...
>
>Mark.
>-----Original Message-----
>From: python-list-admin at python.org
>[mailto:python-list-admin at python.org]On Behalf Of Dirk Leas
>Sent: Saturday, 16 October 1999 1:38
>To: LS, Python
>Subject: Convert ASP Request to sequence (PythonWin)
>
>
>I've installed PythonWin and am trying to do some python scripting w/n
>ASP. If you know the form field by name, something like "name =
>str(Request("name"))" works great. How do you access Request fields if
>you don't know their name -- say you wanted to write a generic dump
>script that would dump all the field names and values? Seems like
>there would be a way to coerce the COM Request into some type of
>python sequence. Anybody know the "secret racoon handshake"?
>
>Thanks
>D
>
>
>
>
>







More information about the Python-list mailing list