Python + IIS/ASP questions (modules, namespaces, etc)
Mark Hammond
mhammond at skippinet.com.au
Wed Dec 18 21:34:46 EST 2002
Preston Landers wrote:
> Pythoneers:
>
> I have some technical questions about the Python ASP server side
> scripting available to IIS users. I've seen someone post some
> questions along the same lines as the questions I have (one is quoted
> below), but unfortunately I have not seen any relevant responses.
> Perhaps I should post this on the Active Python mailing list, as that
> seems to be more win32 oriented.
I don't read that list though <wink>
You should be able to make things work. The quoted posting is missing
the detail that __ax_main__ is never put into sys.modules - thus there
is no real problem with sharing that name. Unfortunately the poster of
that article didn't take into account the observation that it *does*
work, despite his analysis to the contrary.
You can cache any *Python* object you like in the Python ASP engine.
Python will refuse to unload even when asked to by IIS, so global state
will never go away. Normal Python modules imported by ASP pages will
only be imported once, as per normal Python.
There is an issue caching COM objects, and particularly COM objects
passed by, or created by IIS itself. In this case you can still keep a
global reference, but any attempts to later use the object will result
in failure. But caching Python objects is no problem.
Also, IIS has a "global.asa" concept that can be used explicitly to
share global state. I've never used it though (but I hear it works fine
with Python!)
But from what you described, you don't actually need IIS Response or
Session objects or functionality, so it should work fine.
Mark.
More information about the Python-list
mailing list