I'm not sure if this is implemented or not in the Python ASP code or not, but I 
am trying to duplicate some VBS code in Python, and use the URL below as a 
primer as I couldn't find any info on the internet about how Python might 
implement this kind of ASP code.

I know the link is SUPER OLD but it's the best docs I have been able to find on 
the subject.

https://learn.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms524757(v=vs.90)

I am trying to create cookies similar to how the Microsoft Certificate 
Authority Website on Windows Server 2016/2019/2022 does.

Here's my Python ASP code
<% @Language="Python"%>
<%
Response.Write("Here<BR>")
for cookie in Response.Cookies:
    Response.Write(Response.Cookies(cookie)["expires"])

Response.Write(f"dir = {Response.Cookies.__dir__()}")

if not "Type" in Response.Cookies:
    cookie = Response.Cookies["type"] = "peanut-butter" # simplistic example of 
trying to create one

Response.Write("Past Cookie Creation code<BR>")
%>


Here's my error:

Python ActiveX Scripting Engine error '80020009'

Traceback (most recent call last): File "<Script Block >", line 3, in <module> 
cookie = Response.Cookies["type"] = "peanut-butter" File 
"C:\Python310\lib\site-packages\win32com\client\dynamic.py", line 348, in 
__setitem__ self._oleobj_.Invoke(*allArgs), self._olerepr_.defaultDispatchName, 
None COM Error: OLE error 0x80020101
/testcookies.asp, line 5

cookie = Response.Cookies["type"] = "peanut-butter"

Any guidance would be appreciated as I've scoured google for all it was worth.


If it helps....  The VBScript I'm trying to duplicate is:
# snippet of certsrck.inc from the "CertSRV" (MS Certificate Authority) website.

Sub PutRequests(rgRequests)
                Dim sCookie, sRequests, nIndex
                sRequests=""

                ' check for the empty list
                If IsNull(rgRequests) Then
                                ' the list is empty
                                '   do nothing
                                sRequests="-" ' Lynx won't set an empty cookie, 
so set an invalid one
                Else
                                ' the list is not empty
                                ' build a string for each request and 
concatenate to make cookie
                                For nIndex=0 To UBound(rgRequests)
                                                sRequests=sRequests & "[" & _
                                                                
rgRequests(nIndex)(FIELD_REQID) & "," & _
                                                                
rgRequests(nIndex)(FIELD_TARGETSTOREFLAGS) & "," & _
                                                                
rgRequests(nIndex)(FIELD_SAVECERT) & "," & _
                                                                
rgRequests(nIndex)(FIELD_FRIENDLYTYPE) & "]"
                                Next
                End If

                ' Set the cookie
                Response.Cookies(REQUEST_COOKIE_NAME)=sRequests

                ' Set the expiration date
                
Response.Cookies(REQUEST_COOKIE_NAME).Expires=Now+nPendingTimeoutDays

                ' Set the path
                Response.Cookies(REQUEST_COOKIE_NAME).Path="/"

End Sub

Steven
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to