Using Python under ASP

M

Max Ischenko

Hi,

I'm using Python under ASP env. and have a question about how to
communicate Python snippets in different pages.

For example, I'd like to create a per-session object of class FooBar and
be able to access it from any page. How could I do this?

I can't store anything complicated in a Session.
Someone here propose pickle/unpickle an object to the string but that
feels like a kludge. Should I setup some global hash, keyed by SessionID
to store data there?


TIA.
 
S

Steve Holden

Max Ischenko said:
Hi,

I'm using Python under ASP env. and have a question about how to
communicate Python snippets in different pages.

For example, I'd like to create a per-session object of class FooBar and
be able to access it from any page. How could I do this?

I can't store anything complicated in a Session.

Why not? Because Microsoft says so? Becuase your employer says so? What's
"complicated"?

Initially, MS promoted the Session object as the place to store session
state. Then they found that uninformed idiots were saving stupid things like
large ADO resordsets in Session in large numbers, and getting locking and/or
synchronization problems across multiple sessions. Who would have thought
that crappy design could have resulted in crappy performance? Also, the
larger players complained that the mechanism didn't scale across multiple
servers (because it's host-specific).

So the conventional advice became "don't store complex objects in Session,
find some other mechanism". And software vendors and authors made stacks of
money creating and writing about replacement mechanisms.
Someone here propose pickle/unpickle an object to the string but that
feels like a kludge. Should I setup some global hash, keyed by SessionID
to store data there?

If you can convince me that this will actually generate any saving then you
might try it, but personally I'd try saving it in Session and seeing whether
that worked OK for your application. The advantage of pickling would be that
you aren't leaving a reference to an object lying around between page
invocations,.

One last point: if the reason you "can't save anything complicated in a
Session" is because your employer's programming standards say so, then a)
ask them to define "complicated", and b) start dicreetly looking for new
employment :)

regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top