[mod_python] [mod python] ABout Sessions

S.R.Pardá linux at qbox.es
Sat Jun 3 03:54:03 EDT 2006


Hi, 

Sorry to ask again.

I need some acclarations about the session object.


I have been developing VBScripts ASP pages from 1999. I have used a lot
the ASP's session and application objects. Now I'm decided to use PSP
Mod_Python instead.
I'm using Ubuntu, with Apache2 and Mod_Python for server and the Firefox
web client.


1st. Question :
Only One Session is created for various Firefox instances in the same
PC.
In ASP I could open 2 windows with different program views and data, on
different sessions (opening a new explorer. If you select New in menu
Archive with a page opened, you will have a another new page with same
session that the previous page)
Is possible to change how session works to make that ?
If not, can I make only one page could be open to reduce the possibility
of error (I Think in use target="APPL-WINDOW-NAME" in all the links,
that make IE open page in an explicit named window )


2nd. Question:
Usually, in ASP is possible to create a Session referencing a DB
Connection object. So you can use that object to access the server
during the session using that stored connection. In IIS ASP that is fast
and secure.
I have been reading about problems storing not sys objects in sessions,
so I am unsure about that.


3nd. Question:
All the sessions in IIS ASP would have the connection object (yes that I
mencioned in 2nd. point) previously stored because it was stored on a
Session_OnStart() event generated when a page uses Session object and no
Session is active for that petition, defined in global.asa web
configuration,  
So in the pages you can use :
	connectionForThePage = Session('connectionForTheSession')
and OLE! you will have a connection created , because if session not
exist when page load Event will be fired and my code inserted into
on_star will create an object and let it stored in session before the
page executed (so Sesssion('con...') always exist)

Is there a Session_OnStart equivalent in Mod_Python (remember I am using
PSP , I think Publisher can permit write my handler and check that , but
I wanted a transparent method not related to write a handler if it is
possible)


4nd. Question:
Because Apache is threaded, varios modules are opened by various
Mod_python server instances. So the same modules can be loaded more than
one time. So global variables of a module are different to each session,
and to make it hard  possibly different request on same session.
In IIS ASP I could  use application object to store data to be accesed
into different sessions in all the sessions of the server. And
Application object could be LOCKED and UNLOCKED to ensure thread
security.  
In Mod_Python, the only solution its to write a class, that servers
global variables from a Database with appropiate locking ?



Thank You for your patience, sorry if I haven't explained well.


	S.R.Pardá





More information about the Mod_python mailing list