On 2024-10-23 7:42 p.m., Steven Manross wrote:
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.
Response.Cookies is "just" a dynamic COM object/collection and pywin32
has never been great with them and "magic" things like properties etc
due to various semantic mismatches. If you are lucky, there might be a
method on the object taking 2 params? I'm guessing `__dir__` didn't help?
Regardless, a last resort would be to unwrap that __setitem__ call and
experiment with the correct "DISPATCH_*" flags (and in particular,
trying "DISPATCH_METHOD", because the examples are all showing function
calls to "set" a value, which python has no concept of!) - the other
values are probably correct.
HTH,
Mark
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32