HTML writer

M

Moosebumps

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.

It doesn't need to be fancy, just basic tables and linking, maybe indexing
and navigation, but I want it to all look nice and I want to be able to
change the formatting easily without combing through source code (hence my
next question about CSS).

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?

I searched the python website and I have seen HTML parsers, but no examples
of generators. I searched for "Python HTML" and "Python CSS" and found some
stuff -- but it doesn't seem like there is a "standard" solution that is
EASY for non-expert web programmers to use. I am an experienced
programming, but I don't know that much about all the alphabet soup that is
web programming.

thanks,
MB
 
J

John Abel

You could always try HTMLgen, though I don't know how much CSS it supports.

HTH

J
 
?

=?ISO-8859-1?Q?Walter_D=F6rwald?=

Moosebumps said:
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.

There are several possible HTML generators for Python:
HTMLgen http://starship.python.net/crew/friedrich/HTMLgen/html/main.html
HyperText http://dustman.net/andy/python/HyperText/
XIST http://www.livinglogic.de/Python/xist/
[...]
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?

You can do more styling with CSS than you can do with HTML.

Bye,
Walter Dörwald
 
L

Leif B. Kristensen

Moosebumps said:
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?

I don't know anything about Python in relation to dynamic web pages, but
I've worked quite a lot with PHP in this respect. XHTML is a very clean
implementation of HTML, and should, at least in principle, be much more
easily rendered by any browser than ninetyish tag soup. From a coder's
point of view, it also of course has a lot of aesthetic appeal.

The nicest thing about the XHTML/CSS combination, is the clean division
between structure and presentation. The <FONT> tag should go the same
way as the GOTO.

I would recommend to read up the specs of XHTML 1.0 on
<url:http://www.w3c.org/>, write some experimental markup, and then try
to validate it on <url:http://validator.w3.org/>. You'll get the hang
of it after some iterations.

There are many good tutorials on the net for writing XHTML and CSS; do a
search on Google. You can of course also learn an awful lot by viewing
the source of other people's validating pages.

regards,
 
M

Moosebumps

Walter Dörwald said:

Thanks for those links, they look like what I'm looking for. Does anyone
have any comment on which one of these requires you to have the least amount
specific web programming knowledge? i.e. I know basic HTML, and I am an
experienced C programmer, but haven't really delved into the specifics of
it... never really wanted to clutter up my mind with the alphabet soup of
web programming : ). I was thinking that there was some Python library
that would wrap the functionality of these languages in some nice consistent
OO python interface. It looks like all of these are exactly that, from what
I gather, which is great.

That is, I would not like any specific HTML tags anywhere in my own code,
and it seems like that is what they will allow me to do. But I would be
interested to hear opinions/experiences with these packages.

thanks,
MB
 
?

=?ISO-8859-1?Q?Walter_D=F6rwald?=

Moosebumps said:


Thanks for those links, they look like what I'm looking for. Does anyone
have any comment on which one of these requires you to have the least amount
specific web programming knowledge?

Each of them requires you to know what the HTML tags mean.
i.e. I know basic HTML, and I am an
experienced C programmer, but haven't really delved into the specifics of
it... never really wanted to clutter up my mind with the alphabet soup of
web programming : ). I was thinking that there was some Python library
that would wrap the functionality of these languages in some nice consistent
OO python interface. It looks like all of these are exactly that, from what
I gather, which is great.

That is, I would not like any specific HTML tags anywhere in my own code,
and it seems like that is what they will allow me to do. But I would be
interested to hear opinions/experiences with these packages.

As the author of XIST I'm naturally biased, but one advantange of XIST
is that it's still actively maintained. HTMLgen and HyperText don't
seem to be.

To see an example take a look at
http://www.livinglogic.de/viewcvs/index.cgi/LivingLogic/xist/HOWTO.xml.
This XML file doesn't contain any HTML tags, but gets converted to
HTML (see http://www.livinglogic.de/Python/xist/Howto.html), to
XSL-FO (see http://www.livinglogic.de/Python/xist/Howto.fo) and
PDF (see http://www.livinglogic.de/Python/xist/Howto.pdf)

HTH,
Walter Dörwald
 
T

Tuure Laurinolli

Moosebumps said:
That is, I would not like any specific HTML tags anywhere in my own code,
and it seems like that is what they will allow me to do. But I would be
interested to hear opinions/experiences with these packages.

I spent a couple of days last week getting to know each of these. I
found HTMLgen as I was getting desperate with the tag soup in my code
and quickly converted the code to use it. Then I found out it only does
HTML 3.2, missing end tags of elements and such. Some parts of the model
also weren't as generic as they should have been.

Next I stumbled upon HyperText, which seemed to fix all the
incosistencies of HTMLgen, and also output XHTML 1.0. THe problem was
that I found no way to use web forms with it. The 'name'-attribute of an
input tag seemed to be impossible to set(ie. foo.name didn't do the
right thing, foo['name'] was illegal and there weren't any obvious false
names like klass <-> class). Fixing this would have been easy, but I
decided to look for alternatives.

The final option seemed to be XIST, of which HTML seems to be only small
part. It seems to implement HTML in a consistent fashion, allowing all
the necessary tag attributes to be set and otherwise providing a nice
interface to the horrible world of web :)

-- Tuure Laurinolli
 
M

Moosebumps

Thanks to all for the feedback -- that was very useful! I think I will go
with XIST.

MB

Tuure Laurinolli said:
Moosebumps said:
That is, I would not like any specific HTML tags anywhere in my own code,
and it seems like that is what they will allow me to do. But I would be
interested to hear opinions/experiences with these packages.

I spent a couple of days last week getting to know each of these. I
found HTMLgen as I was getting desperate with the tag soup in my code
and quickly converted the code to use it. Then I found out it only does
HTML 3.2, missing end tags of elements and such. Some parts of the model
also weren't as generic as they should have been.

Next I stumbled upon HyperText, which seemed to fix all the
incosistencies of HTMLgen, and also output XHTML 1.0. THe problem was
that I found no way to use web forms with it. The 'name'-attribute of an
input tag seemed to be impossible to set(ie. foo.name didn't do the
right thing, foo['name'] was illegal and there weren't any obvious false
names like klass <-> class). Fixing this would have been easy, but I
decided to look for alternatives.

The final option seemed to be XIST, of which HTML seems to be only small
part. It seems to implement HTML in a consistent fashion, allowing all
the necessary tag attributes to be set and otherwise providing a nice
interface to the horrible world of web :)

-- Tuure Laurinolli
 
H

has

Moosebumps said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,181
Messages
2,570,970
Members
47,536
Latest member
VeldaYoung

Latest Threads

Top