HTML writer

has has.temp2 at virgin.net
Sat Apr 3 18:05:31 EST 2004


"Moosebumps" <moosebumps at moosebumps.com> wrote in message news:<yL9bc.45202$wH3.33614 at newssvr25.news.prodigy.com>...
> Is there a standard solution for writing HTML web pages with Python?  I
> don't know that much about web programming, but basically I want to generate
> some internal reports on a web page.

First ask yourself if you need to generate pages dynamically, or is
pre-rendering and serving them up statically fine? The latter is much,
much simpler to code for. For what you describe this may be all you
need. There's no shortage of frameworks for doing the former though (I
believe Quixote is well regarded as a "programmer-friendly" solution,
for example).

For templating, as long as you're comfy with a modicum of OO
programming then I'd recommend my HTMLTemplate module:
<http://freespace.virgin.net/hamish.sanderson/htmltemplate.html>.
Compiles HTML templates to a simple Python object model than can be
manipulated programmatically. Small and simple with no external
dependencies, clean separation between code and markup, and a very
clean, compact API; easily outstrips the old-school bloatware
ASP/PSP-style systems with their horrible code-in-markup soup.

On the offchance you need to do arbitary markup generation (for
generating really irregular tables and stuff that can't easily be
templated), there's always HTMLgen but it's pretty old and hoary now.
Donovan Preston's Nevow.Stan module is much more modern; see
<http://www.python.org/pycon/dc2004/papers/60/Nevow2004Tutorial.html>
for an introduction.


> I know there newer things like CSS and XHTML -- are these more or less
> effort to generate?  i.e. are they more complicated, or do they have more
> uniform syntax?  What do they necessarily buy you?

CSS (cascading style sheets) are for styling (and - if you're brave -
page layout). Absolutely fine for styling text (waaay nicer than using
<font> tag crap). Many browsers still have problems with more complex
presentational stuff, but it doesn't sound like you'll be needing
that. Not something you should have to generate programmatically -
whole point of CSS being you just write it once and apply it to your
entire site.

XHTML is just a tidied up version of the HTML standard; enforces a few
things that were optional in HTML, e.g. correct closing of element
tags, the main advantage of this being it can be parsed, manipulated,
etc. as XML.


> I am an experienced
> programming, but I don't know that much about all the alphabet soup that is
> web programming.

Yeah, there's a lot o' crap to avoid out there. Still, a good start'd
be finding yourself a nice modern introduction to writing HTML and
CSS, and go from there. There's scads of stuff online for this - main
problem's knowing the good from the bad. Reckon you some find some
good links at <http://webstandards.org/learn/standards/> (though you
may have to sift through a bit of geeky buzzword evangelism waffle to
get to it:). You won't need the advanced stuff and the basics are
easy. (Honest.<g> Hint: if a tutorial makes it sound complicated, find
a better tutorial!)

HTH



More information about the Python-list mailing list