Python web development, really

A.M. Kuchling amk at amk.ca
Tue Jan 21 17:37:49 CET 2003


Afanasiy wrote:
> In my commandline scripting tests, Python always beats PHP...
> What would stop a new Apache+Python integration project from being faster?

Perhaps Richard knows the Zend optimizer for PHP is faster, or assumed 
it would be.  If you've measured Python at being faster, though,
that would settle the performance question for you.

>>>* 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
> Not from what I have seen. I even imagine implicit vs. explicit would
> cause many Python programmers to love writing cascading header/footer
> includes and custom error handling on every new page, even if via paste.

Indeed, I'd imagine support for this to be rare.  Doing it explicitly 
isn't a huge amount of work, though, and I'd hope it can be reduced
to a line or two.  For example, once you've written header() and
footer() functions, pages look like this using Quixote's PTL:

from <wherever> import standard

def simple [html] ():
     standard.header('Login')

     '<h1>Welcome!</h1>'
     ... blah blah ...

     standard.footer()

There are lots of different ways to tweak the HEAD element, though,
and to present additional things, so header() can get quite complicated:

def fancy [html] ():
     standard.header(title='Application Login',
                     author='webmaster at amk.ca',
                     description="Login page for a nifty application",
                     keywords="login, log-in, application, app,webapp..."
                     # titles for breadcrumb links
                     crumbs = ['Home', 'Application'],
                     )

It would be hard to make things this flexible with an automatic headera
and footer system, and in the common case (just supplying a title)
the overhead is low, so I find this an acceptable trade-off.

A toolkit certainly shouldn't require cut-and-paste programming, though,
but should support factoring out the common code into 
sub-functions/methods/pages/<metaphor>s.

> Which platform do you recommend I test for all of these requirements?
> Many tested so far fail relatively easily. I am looking for concrete
> suggestions from people experienced in this sort of web development.

I think the problem with offering a recommendation is that you haven't 
said in what respect they fail.  Too low-level?  Too many assumptions
that don't fit your situation?

There are so many different design approaches and requirements for web 
applications that it's unlikely one toolkit could ever work for every 
one, explaining why there are so many different ones out there.

--amk







More information about the Python-list mailing list