PSP, Cheetah, PTL, ZOPE, etc ...

Benji York benji_york at
Fri Aug 3 16:10:05 CEST 2001

grahamd at (Graham Dumpleton) wrote...
> Thanks for the analysis and pointers. Gives me more to think about.
[snip info about his project]

Something I haven't seen presented here yet:  When starting a new
project to create web interfaces for several databases I decided
against the templating approach (for reasons addressed elsewhere on
this thread).  I started with HTMLgen, but soon found it to be
lacking.  I wrote a simple OO-ized HTML generating library that has
grown over the last year, but is still quite simple to use.  It
reflects my desire to write Python code that looks like Python, but
ultimately generates HTML.


# Build a table.
table = Table(width='100%', border=1)
table.newCell(Font('bar', size='+1'), bgColor='#CCFFFF')
table.newCell(NoBreak('A really long cell.'), columnSpan=2)
print table

Results in:

<table width="100%" border="1"><tr><td>foo</td><td
bgcolor="#CCFFFF"><font size="+1">bar</font></td></tr><tr><td
colspan="2"><nobr>A really long cell.</nobr></td></tr></table>

As noted before in the thread, you very quickly build up your own more
complex objects, so the top level of your app has mostly more
sophisticated objects.  One example would be the Box class that I
created.  Conceptually it's just a container that draws it's contents
on a colored field with a different color border.  It's easy to stuff
any other object (or anything with a __str__ function) into them.  It
uses the HTML objects underneath to do it's thing.

The reason I choose this approach is that we are an all-programmer
shop, where we have to do the HTML too.  Therefore tightly integrating
it to the code (but keeping presentation seperate from logic, etc.)
makes more sense than trying to design the HTML separately.

I'm hoping to clean up the code and release it soon, any interest?

Benji York

More information about the Python-list mailing list