Re[2]: [python-win32] ASP Python

Jim Abrams Jim Abrams <jabrams@publishingresources.com>
Wed, 11 Jul 2001 16:45:23 -0400


MM>> Being able to store stuff in the application object, by the way, is
MM>> really useful for ASP programming (at least the stuff I’m working on).
MM>> It allows you to maintain a state across your web application from
MM>> request to request.  The caveat is that anything you want to store in
MM>> the Application object has to be able to fit inside a VARIANT.

JA> Which, to my dislike, means no dictionaries. Although a quick
JA> dict.items() can go in, and mx.Tools has a function called dict()
JA> which will take the items() list and rebuild a dictionary at C-level
JA> speed.

MM>> Futhermore, if the thingy you want to store is an object (like
MM>> VT_DISPATCH), then it has to be free-threaded (I’m not so sure about
MM>> this restriction).  This is a bummer, because I would like to store Perl
MM>> or Python’s rich data structures in there.

Something was tickling the back of my mind when I read this, and
here's a suggestion.

Since Python modules are cached, you could create an empty module,
and use that as a replacement for the Application object's
persistence mechanism. You'd have to work about it being thread-safe,
but you can store arbitrary Python objects there. Infact it would
probably be easy to create a Session manager as well using the same
idea. Anyone know why this might not be a good idea?

Some crude, quick tests showed the Python module to be about twice as fast as
Session.

If anyone does anything with this it would be helpful to post some
results and ideas.