so how do *you* generate XHTML?

Jacob Smullyan smulloni at smullyan.org
Fri Jan 17 22:30:00 EST 2003


In article <slrnb26aej.1hr.nthomas at rain.cise.ufl.edu>, N. Thomas wrote:
> I've got some data that I'd like Python to spit out into XHTML, and I
> don't want to print out raw XHTML strings, ala (print '<title>%s</title>
> % body['title']).
> 
> After looking around a bit, the only module I can find that can do this
> is HTMLgen, which was exactly what I was looking for. The only problem
> is that HTMLgen is about 4 or 5 years old, and AFAIK, hasn't been
> developed further since then.

> My question: Is there a newer version of HTMLgen or is there a newer
> tool that does the same thing as HTMLgen?


If  all you want to do is produce xhtml elements through a simple api,
reminiscent of Apache's ECS or Cgi.pm, you can use ecs, which is in
SkunkWeb CVS:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/skunkweb/skunkweb/pylibs/ecs/

You use it like so:

tr=ecs.Tr(ecs.Td(ecs.A('click here').setAttribute('href', 'http://click.com')))
print ecs.Html(ecs.Body(ecs.Table(tr)))

The ecs elements are modifiable, so you can pass them around and
subject them to operations if you like.  Sometimes it is just neater
to use these little objects rather than html strings; sometimes there
is just no point to doing so, however!

js




More information about the Python-list mailing list