Re: [Web-SIG] Pure Python HTML?

2005-04-13 Thread Martijn Faassen
Bill Janssen wrote:
I don't know about you, but generating HTML with pure Python code can be
messy--ONE reason why we introduce templateing languages in the first
place. Often (not always) the best way to end up with XHTML is to start
with a valid or almost-valid XML document and then infuse the dynamic
content.

Indeed.  And in Python I do it with string formatting:
[snip]
This works for small scale projects where only a few developers are 
expected to know the codebase. But in a larger scale project where you 
have to work with web designers which may not know a lot of Python, this 
doesn't really work.

There are also other aspects, like i18ning your HTML, which would be 
hard to do with your example.

It's the black box principle; I don't want to go through your Python 
code just to tweak a bit of HTML. The idea of ZCML is for programmers to 
be able to reconfigure or extend the behavior of other people's code 
without having to change, or hopefully even fully understand, that code 
itself. The idea is that this pays off once you are working in a larger 
scale project or cluster of projects, like in the Zope community.

I don't think this discussion will go anywhere though, as your position 
seems to be too extreme in this respect to easily move out of. :)

Regards,
Martijn
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] Pure Python HTML?

2005-04-13 Thread Bill Janssen
 This works for small scale projects where only a few developers are 
 expected to know the codebase.

Sure.  It was a small scale example.  For larger projects you'd use
more abstraction layers, accessing (for example) template strings via
method calls which would provide the ability to do things like i18n
manipulation.

 The idea of ZCML is for programmers to 
 be able to reconfigure or extend the behavior of other people's code 
 without having to change, or hopefully even fully understand, that code 
 itself.

Sound engineering principles, modularity and abstraction.  Now let's
glue those modules together with Python rather than with XML.

 I don't think this discussion will go anywhere though, as your position 
 seems to be too extreme in this respect to easily move out of. :)

Gosh, I barely have a position on this, really.  I'm just interested,
on this mailing list, in improving ways of helping Python-savvy
engineers provide and use Web services.

Bill

___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com


Re: [Web-SIG] Pure Python HTML?

2005-04-12 Thread Bill Janssen
 I don't know about you, but generating HTML with pure Python code can be
 messy--ONE reason why we introduce templateing languages in the first
 place. Often (not always) the best way to end up with XHTML is to start
 with a valid or almost-valid XML document and then infuse the dynamic
 content.

Indeed.  And in Python I do it with string formatting:

template = 
HTML
HEAD
TITLE%(title)s/TITLE
/HEAD
BODY
H1%(title)s/TITLE
PAuthor:  %(author)s
Psomething interesting here
/BODY


dynamic_content = {}
# fill in dynamic content here, or perhaps it's a dict read from a DB
dynamic_content['title'] = 'How to write a Web service'
dynamic_content['author'] = 'Someone Good'

request.reply(template % dynamic_content)


Bill
___
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com