Convert ASP Request to sequence (PythonWin)

Nikolai Kirsebom nikolai at micon.no
Wed Oct 20 18:17:10 EDT 1999


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