Pythonic way of web-programming

Graham Fawcett graham__fawcett at hotmail.com
Mon Apr 7 13:23:03 EDT 2003


Lothar Scholz wrote:
> lekishvili at python.qartu.com (Giorgi) wrote in message news:<a3b5b608.0304040904.146dfff5 at posting.google.com>...
> 
>>- Is Python a real web-programming language at all? I mean, has
>>somebody ever used it for real, commercial tasks? Please, do not
>>consider my question too trivial. There is no language equally
>>suitable for all tasks, however, Python seems to me a language
>>naturally tailored for web-programming; this or that way, I have more
> 
> 
> No its not a naturally tailored web-programming language, because it
> is
> very hard to integrate in Server Pages. You have to change the
> indentation syntax/semantic of python to embedd it in a real useable
> way.
> This is done by Webware but it looks very strange to normal python
> programmers.
> 
> Of course you can use template systems. But this is not always a good
> economic decision.

Lothar, "not integrating well in Server Pages" is an incomplete argument 
against Python as a Web programming language, IMHO.

First, "Server Pages" are a subset of a much larger range of 
"templating" solutions. Server Page schemes tend to have a lot of code 
embedded between pseudo-HTML tags, interspersed with HTML snippets. They 
also tend to be unmaintainable, and often get polluted with application 
logic, when they should be focusing on presentation alone.

If the script in your Server Page is doing much more than iterating a 
list of elements, calling code from a Python module (that you wrote, or 
that's in the standard library), or doing a bit of string manipulation, 
then it's time to stop writing code for a while, Google "separate logic 
from presentation" and think about your approach until you're really 
sure you've got your concerns separated.

I would agree with you that Python isn't overly well suited to the 
Server Page approach, though I've used it in ASP with very few problems 
caused by indentation. Let's not count the language out quite yet...

Python has some outstanding templating options. I think, e.g., that 
ZopePageTemplates (doesn't require Zope, btw) is a work of art, and 
avoids many of the inherent design flaws that mar most templating 
approaches. If you need it to, ZPT will coexist very peacefully with Web 
designer tools (Dreamweaver, etc.), *far* better than most other 
templating systems will, regardless of what language those systems 
favour. And, best, ZPT makes it very *hard* to put application logic 
into the page, thus forcing you to consider presentation alone, a very 
helpful design constraint indeed.

Or, take a look at Quixote's approach to templating. It turns the whole 
concept inside out, and gives a programmer-friendly way of building Web 
output without inventing an pseudo-HTML minilanguage to struggle with. A 
great approach that builds on Python's flexibility and strengths.

But the big point is that there is far more to Web application 
programming than templating. Templating is the easy part! There's domain 
modelling, business logic, scripting, persistence management, database 
access, code maintainability, RAD, developer effectiveness, etc. Python, 
most lithe of modern languages, seems an excellent fit to these more 
serious needs.

Best,
-- Graham




More information about the Python-list mailing list