Session CGI!

J

John

I need a web app framework in python with support for session
management (ala ASP/PHP). However, unlike some modules I found, I need
to integrate with an existing Apache install without opening any new
application server ports (not my server). Is there such a module which
I can just toss it into pythonpath and get to work?
 
S

simo

I need a web app framework in python with support for session
management (ala ASP/PHP). However, unlike some modules I found, I need
to integrate with an existing Apache install without opening any new
application server ports (not my server). Is there such a module which
I can just toss it into pythonpath and get to work?

You could use cookies and/or database writes. Never been a big fan of
PHP sessions myself - they are basically temp files and GET variables
after all....
 
T

Tim Roberts

Sadly that is what I want to avoid :-(

Well, there isn't any magic avaiable, even in Python. Either you use a
port and an appserver or you store your session data somewhere. I'm not
sure what you were hoping to find.
 
H

Harry George

Erno Kuusela said:
see here: http://www.catdancers.com/webmags/webtech/1998/03/perl/

it's about perl, but you can apply the idea to python too.

-- erno


There are two problems:

1. Where to store state. Databases, cookies, and pickle files are
available. I've used pickle files for low volume apps.

2. How to structure the CGI code. Of course, something like webware
or twisted would hide it all, but let's assume you are writing from
scratch. Since this is a stateless protocol, we can borrow from
another (and solved) stateless protocol -- sockets.

So for each webpage,we make 2 functions (or methods): send_xyz and
recv_xyz. On wakeup,we check a hidden field to determine which
"xyz" is arriving, and call its recv. There we use another hidden
field (or an SSL tag) to get the right database or pickle data and
load it into an object. Continue processing as if there was no
time gap. At end (ready for more user input), call the proper
"send". It prepares the hidden fields, saves the state, and prints
the outgoing page. The script exits and we are back at the
browser.
 
J

John

Tim Roberts said:
Well, there isn't any magic avaiable, even in Python. Either you use a
port and an appserver or you store your session data somewhere. I'm not
sure what you were hoping to find.


I am not looking for magic. What I am looking for is an elegant
solution to manage session info like in ASP/PHP, both of which have
doing this for quite a while. It's hardly exotic. It has been a couple
of years since I last used ASP, but I think it was session("var") =
value in ASP. Can't be simpler than that. Similar stuff in PHP
session_register. It manages Client side Cookies under the hood. Nicer
if the session info is maintained as server side cookies with a unique
SessionID. At this point, I do not know if that can be done. Sessions
are important for me since the site is membership based.

All these nice and comprehensive Python web app framewoks I looked at
so far DO have session support but need additional ports to be open or
act their own servers. That's OK if you have your own machine for
server but my admin will think twice before he installs one of those
for my non-critical app. PHP does not seem to need that. But I prefer
Python if I can help it.

If I don't find quick 'n' easy session management, maybe I will at
least figure out common web app design patterns with cookies.
 
D

DH

John said:
I am not looking for magic. What I am looking for is an elegant
solution to manage session info like in ASP/PHP, both of which have
doing this for quite a while. It's hardly exotic. It has been a couple
of years since I last used ASP, but I think it was session("var") =
value in ASP. Can't be simpler than that. Similar stuff in PHP
session_register. It manages Client side Cookies under the hood. Nicer
if the session info is maintained as server side cookies with a unique
SessionID. At this point, I do not know if that can be done. Sessions
are important for me since the site is membership based.

All these nice and comprehensive Python web app framewoks I looked at
so far DO have session support but need additional ports to be open or
act their own servers.


You want session cookies stored as temp files instead of in a database.

To do it with Quixote see the session persistence section here and the
session_demo.cgi file included with Quixote:
http://www.mems-exchange.org/software/quixote/doc/session-mgmt.html

Spyce is a little more like ASP & PHP, see this doc, esp. the auto-
session handling part, which can work with or without cookies:
http://spyce.sourceforge.net/doc-mod_session.html
 
J

John

DH said:
You want session cookies stored as temp files instead of in a database.

To do it with Quixote see the session persistence section here and the
session_demo.cgi file included with Quixote:
http://www.mems-exchange.org/software/quixote/doc/session-mgmt.html

Spyce is a little more like ASP & PHP, see this doc, esp. the auto-
session handling part, which can work with or without cookies:
http://spyce.sourceforge.net/doc-mod_session.html

Hi DH,
I am looking at Quixote and Spyce. Both are very nice and fit my needs.

Thanks,
John.
 

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
474,183
Messages
2,570,967
Members
47,518
Latest member
RomanGratt

Latest Threads

Top