Python web development, really

Ian Bicking ianb at
Thu Jan 23 22:57:33 CET 2003

I'm a developer for Webware (, so I'll answer the
questions with relation to Webware:

On Mon, 2003-01-20 at 11:16, Afanasiy wrote:
> * Run on the same hardware I use currently

Yes, so long as you can run long-running processes.  Most commercial
shared-hosting situations don't allow this.  This applies to all Python
frameworks except when accessed strictly through CGI, which will give
you atrocious performance.

> * Be as fast or faster than Apache+PHP
>   (I'm sorry to say Zope/Roxen are not)
>   (This might mean it must use Apache)

Probably comparable speed.  It's definitely faster than Zope.  We
haven't encountered people who have felt limited by the speed of Webware
(as compared to bandwidth limitations, database, etc).  But that might
just be because people aren't using in situations where it would be a

Webware also makes possible some significant caching, though you have to
do it in an ad hoc way.  You'd do this through global data, which is
noted later.

> * Use a similar amount of memory
>   (ie. not Java/.NET related)

Webware is fairly small, it should be fine.

> * Provide a fairly equivalent framework w/ sessions, cookies, get, post
>   (Described in
>   (eg. I should not have to write code to parse query strings, etc.)
>   (PHP is somewhat unique in the ways it can bring in post variables)

Yep, they all do that.  Of course it doesn't register variables as
globals, but that's a feature :)

> * Allow all errors to be caught and handled so users never see them
>   (I currently send them to an email address)
>   (Users are notified an error occurred and a developer contacted)


> * Allow sending of email

Through smtplib.  We don't duplicate anything that Python does fine on
its own.

> * Allow sending of raw binary data, for restricted file downloading
>   (eg.
>   (This requires header manipulation, specifically the mime type)
>   (That sort of thing should be part of the framework 3 bullets up)


> * Allow SSL secured credit card processing
>   (I currently use PHP's libcurl+ssl module)

You'd do this using urllib, which is part of Python.
> * Allow similarly powerful regex capabilities
>   (I currently use PHP's pcre module)

Again, using Python's re module (IMHO much easier to use than in PHP).

> * Big plus, but optional, auto prepend/append files
>   (eg. Apache+PHP has .htaccess directives like this )
>   (    php_value auto_prepend_file "_header.php"     )
>   (    php_value auto_append_file "_footer.php"      )
>   (granular down to the directory 

I believe there's ways to do this with Apache while using Webware.  But
you can (in effect) do this in Webware fairly easily.  Each page of a
Webware application is a separate class.  Generally there will be a
superclass that you write that is specific to your application.  In it
you can put a header and footer, and those can be as dynamic as you

> * Finally, very optional plus, global application scoped variables
>   (PHP does NOT allow this, but I know why)
>   (I do not want to hear why you think this is bad)
>   (I know why it is good, I know why it can be bad)

If I understand what you're thinking, yes, Webware does this well. 
Webware runs in a single, multi-threaded process.  So say you want to
keep a global list of everyone logged on: you'll have a global variable
in some module, and use .append() to add users or .remove() to remove
them.  All servlets can access the same variable.  Of course you have to
be careful to work with the data in a threadsafe manner, which is
inevitable (and of course the same concurrency issues exist in PHP as

This data can be used for caching.  IMHO the convenience of this caching
makes increasing performance easier in Webware than, say, SkunkWeb
(which uses multiple processes, and so makes data sharing harder). 
SkunkWeb claims the multiple processes mean that it can better utilize
multi-processor systems because it is not pinned by the global
interpreter lock.  This is true, but there are many ways to increase
performance, and I believe easy data sharing and caching is more of a
benefit than multiple processors would be.  But anyway, I digress...

So, in conclusion, PHP is very expedient, and if you are making
applications where expedience is important, then PHP probably will work
well for you.  If you are making larger more powerful applications where
design really matters, then Python has some benefits over PHP.  And they
are big benefits -- PHP as a language is horrible, horrible, horrible. 
And it's not even a matter of compromises -- PHP doesn't *have* to be
that horrible, most of its flaws aren't tied to its conveniences.  It
just chooses to be horrible.

Ian Bicking           Colorstudy Web Development
ianb at
PGP: gpg --keyserver --recv-keys 0x9B9E28B7
4869 N Talman Ave, Chicago, IL 60625 / (773) 275-7241

More information about the Python-list mailing list