[Web-SIG] Useful ideas from PHP

Ian Bicking ianb at colorstudy.com
Fri Oct 17 14:48:13 EDT 2003


On Friday, October 17, 2003, at 10:56 AM, Simon Willison wrote:
> I've been working with PHP for several years, but have recently 
> started to make the switch to Python for web development. There follow 
> some thoughts on PHP's web development capabilities compared to 
> Python's. PHP has a number of tricks that are worth borrowing for the 
> Python standard library - although in my opinion the ability to embed 
> code in HTML is not one of them.
>
> Things PHP does better than Python
> ==================================
>
> * $_GET, $_POST, $_COOKIE, $_FILES, $_REQUEST, $_SERVER, $_ENV
> http://www.php.net/manual/en/language.variables.predefined.php

This is really PHP vs. the Python cgi module.  Other Python web 
frameworks do most of these things (some don't differentiate between 
GET and POST variables, most use a different way of indicating files, 
and there's some other features that are sometimes included in 
frameworks and sometimes not, like access to the raw POST data or 
streaming output).

So really this is a matter of getting Python's stdlib to include some 
of the functionality that has been widely implemented elsewhere.  Or at 
least, that's one possible goal.

> * header(), setcookie()
> http://www.php.net/manual/en/features.cookies.php

AFAIK, all frameworks (besides cgi) handle this.

> These functions allow a user to manipulate the headers being sent back 
> to the user and provide an easy method for setting cookies. In Python 
> CGIs you have to manually ensure you send the headers before any HTML 
> by being careful with your print statements. Some kind of abstraction 
> for headers is a good idea.
>
> * Native session support with session_register and $_SESSION
> http://www.php.net/manual/en/ref.session.php

And most handle this as well.

--
Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org




More information about the Web-SIG mailing list