Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Persistent Session in CGI

Reply
Thread Tools

Persistent Session in CGI

 
 
keegan.csmith@gmail.com
Guest
Posts: n/a
 
      08-27-2006
Hi,

I have started a new small web project, and was wondering if there are
any good guides on how to do Persistent Sessions and Authentication
using python and CGI. I don't really want too use Zope, because It's
probably overkill for my tiny project.

 
Reply With Quote
 
 
 
 
Paul Rubin
Guest
Posts: n/a
 
      08-27-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) writes:
> I have started a new small web project, and was wondering if there are
> any good guides on how to do Persistent Sessions and Authentication
> using python and CGI. I don't really want too use Zope, because It's
> probably overkill for my tiny project.


The simplest thing to do is put all the session info into a browser
cookie. That limits the amount of session info but maybe you can live
with that. You should encrypt and authenticate the cookie to prevent
the user from tampering with it.
 
Reply With Quote
 
 
 
 
Fuzzyman
Guest
Posts: n/a
 
      08-27-2006

(E-Mail Removed) wrote:
> Hi,
>
> I have started a new small web project, and was wondering if there are
> any good guides on how to do Persistent Sessions and Authentication
> using python and CGI. I don't really want too use Zope, because It's
> probably overkill for my tiny project.


You could try my 'logintools' CGI module (mini framework really, but
very mini).

It handles authentication for you, and provides a mechanism that you
could use to create persistent sessions.

http://www.voidspace.org.uk/python/logintools.html

(It uses cookies).

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

 
Reply With Quote
 
Damjan
Guest
Posts: n/a
 
      08-31-2006

> I have started a new small web project, and was wondering if there are
> any good guides on how to do Persistent Sessions and Authentication
> using python and CGI. I don't really want too use Zope, because It's
> probably overkill for my tiny project.


Since you only mention Zope...
Why not use TurboGears or Pylons or CleverHarold ... or anything WSGI based.
Or if you want to make something minimal you could try Paste with
(optionally) RhubarbTart.

But.. WSGI is the new CGI (the lowest common denominator) in Python web
development. So use it.
The benefits:
You can run your app as CGI, in mod_python, as a standalone http server,
with SCGI/FastCGI.
You'll benefit from authentication and session middleware. Middleware is a
great WSGI concept, there are also caching middlewares etc..



--
damjan
 
Reply With Quote
 
Damjan
Guest
Posts: n/a
 
      08-31-2006
> But.. WSGI is the new CGI

Let me give you a minimal example using RhubarbTart (it depends on Paste)

from rhubarbtart import request, response, expose
from rhubarbtart import TartRootController

class Root(TartRootController):
@expose
def index(self, msg="Hello world!"):
response.headers['Content-type'] = 'text/plain'
return msg

app = Root()

#
# Now to serve it as a CGI script, just:
#
from wsgiref.handlers import CGIHandler
CGIHandler().run(app)

#
# or to server it in a long running python-based HTTP server
#
from paste import httpserver
httpserver.serve(app)

# END of example

Now this is just the begining to show you that it's not hard.
But when you see what EvalException can do for you, you'll beg for more

Hint:
from paste.evalexception.middleware import EvalException
app = EvalException(app)
# then serve the app in the paste httpserver ...
# but make some error in your python code to see it's results


--
damjan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Persistent field and Persistent properties - difference gk Java 7 10-12-2010 09:43 PM
Accessing a Persistent Object throughout a user session =?Utf-8?B?QWxleCBNYWdoZW4=?= ASP .Net 3 04-14-2006 12:35 PM
Persistent Forms Authentication - and Session Variables Max ASP .Net 5 01-03-2005 04:42 AM
persistent CGI pattern at google.com (was why python?) francois lepoutre Python 1 11-19-2004 12:37 PM
Python CGI as persistent network client. jbi130@yahoo.com Python 0 10-21-2003 04:57 AM



Advertisments