Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > PHP session equivalent?

Reply
Thread Tools

PHP session equivalent?

 
 
Erik Johnson
Guest
Posts: n/a
 
      02-12-2005

There are a lot of things about PHP I was not too keen on and hence why
my company is primarily doing Python these days, but one thing I was quite
impressed with was the ease with which it provided session functionality...

<?php

session_start();
session_register['my_var'];

$my_var = "whatever";

?>

And then in another CGI script do basically the same thing and get the
value of $my_var back. Setting of a session ID cookie happens automagically.
This is quite handy and simple.

I don't think it's quite so simple in Python (which is not to say I
think PHP is better than Python). Doing a little extra work is no big deal,
but could someone be so kind as to lay out what needs to be done for a
Python CGI script to get essentially the same functionality? Are there
Python modules that implement a lot of this already?

We are currently running under an Apache server (on SuSE Linux 8.2). I'm
not clear on whether some session functionality is provided there? We may be
moving to Zope before too long (trying to find some time to evaluate it), so
a method that is not strictly dependent on Apache would be preferable (in
the short term that may suffice).

Thanks for taking the time to read my post!

-ej


 
Reply With Quote
 
 
 
 
Walter Burleigh
Guest
Posts: n/a
 
      02-12-2005
Erik Johnson wrote:

> There are a lot of things about PHP I was not too keen on and hence
> why
> my company is primarily doing Python these days, but one thing I was quite
> impressed with was the ease with which it provided session
> functionality...


Like you I think it is a big plus of PHP as a beginner's web development
tool that it provides session management out of the box. It would certainly
make python more attractive for beginners if they could use session
management out of the box, too. (I know that there are lots of web
development frameworks, but they are to be too difficult to learn, if you
are new to web development).

There is no module for session management in the python standard library.
But there are lots of python frameworks that would do this job well (my
favorite: cherrypy). If you think that a whole framework would be overkill,
you either could try to recylce the session part of an existing framework,
or you could write a module for yourself.

I have written a module which is quite similar to the php session
management, except for that it does no url rewriting when cookies are not
allowed. If you are interested, I will mail you a copy.

 
Reply With Quote
 
 
 
 
Reinhold Birkenfeld
Guest
Posts: n/a
 
      02-12-2005
Walter Burleigh wrote:
> Erik Johnson wrote:
>
>> There are a lot of things about PHP I was not too keen on and hence
>> why
>> my company is primarily doing Python these days, but one thing I was quite
>> impressed with was the ease with which it provided session
>> functionality...

>
> Like you I think it is a big plus of PHP as a beginner's web development
> tool that it provides session management out of the box. It would certainly
> make python more attractive for beginners if they could use session
> management out of the box, too. (I know that there are lots of web
> development frameworks, but they are to be too difficult to learn, if you
> are new to web development).
>
> There is no module for session management in the python standard library.
> But there are lots of python frameworks that would do this job well (my
> favorite: cherrypy). If you think that a whole framework would be overkill,
> you either could try to recylce the session part of an existing framework,
> or you could write a module for yourself.
>
> I have written a module which is quite similar to the php session
> management, except for that it does no url rewriting when cookies are not
> allowed. If you are interested, I will mail you a copy.


If you need session management, and do not want a complicated web app
framework, check out pso: http://pso.sf.net

Reinhold
 
Reply With Quote
 
Jason F. McBrayer
Guest
Posts: n/a
 
      02-13-2005
"Erik Johnson" <(E-Mail Removed)> writes:

> I don't think it's quite so simple in Python (which is not to say I
> think PHP is better than Python). Doing a little extra work is no big deal,
> but could someone be so kind as to lay out what needs to be done for a
> Python CGI script to get essentially the same functionality? Are there
> Python modules that implement a lot of this already?


Take a look at jonpy (jonpy.sourceforge.net). jon.session does pretty
much exactly what you want. There are lots of other python web
frameworks that also provide this, but jonpy is one of the smallest
and conceptually simplest.

--
+----------------------------------------------------------------+
| Jason F. McBrayer http://www.velocityreviews.com/forums/(E-Mail Removed) |
| "If you wish to make Pythocles wealthy, don't give him more |
| money; rather, reduce his desires." -- Epicurus |
 
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
PHP Training Institute In Delhi, Live Projects on PHP. Short TermPHP Courses, PHP Scripts, PHP Training with Live Projects. Rajive Narain Java 0 09-18-2009 10:47 AM
Best site for freelancer work (PHP, Web site, java, oracle sql, php,data entry) raviraj joshi NZ Computing 0 07-04-2009 03:05 PM
Learn how to edit php pages with free php editor torque63 HTML 0 01-01-2009 03:45 AM
RE: php and python: how to unpickle using PHP? Ted Zeng Python 0 10-13-2006 12:11 AM
php and python: how to unpickle using PHP? Ted Zeng Python 4 10-03-2006 03:07 PM



Advertisments