Any python HTML generator libs?
Steve Holden
steve at holdenweb.com
Thu Mar 9 15:57:26 EST 2006
Sullivan WxPyQtKinter wrote:
> Hi, everyone. Simply put, what I need most now is a python lib to
> generate simple HTML.
>
> I am now using XML to store my lab report records. I found python
> really convinient to manipulate XML, so I want to make a small on-line
> CGI program to help my colleagues to build their lab report records
> into XML, for storage, HTML display (for others to browse) and search.
>
> With python's standard lib, the DOM object could realize the XML
> storage and search quite easily, but for HTML generation, it is a
> great headache.
>
> I tried to turn to the in-line server-side python script PSP(something
> like asp and php) instead of CGI. However, since the report data is
> always of very complex data structures, it is really hard to write most
> things in-line. For example, a PCR reaction is expected to be shown in
> this format or alike on a web browser:
>
> PCR
> Sample: Sm1032
> Operater: SullivanZ
> TimeStamp: hh:mm mm-dd-yyyy
> Reaction:
> Reagent1:
> Name:XXXX
> Concentration:XXXX mM
> Volumn:XXX uL
> Reagent2:
> ........................
> ........................
>
> Since there are hundreds of PCR reaction and other operations in the
> lab report, in-line PSP is not a suitable solution. But writing HTML
> directly with print statement is a great pain.
>
> Will XSTL be useful? Is my problem somewho related with XML-SIG?
> Looking forward to your precious suggestion.
>
The triple-quoted string with string substitution is your friend. Try
writing something(s) like:
results = {'secnum': 1, 'type': 'string', 'color': 'blue'}
print """\
<h1>Section %(secnum)s</h1>
<p>Elements of type %(type)s should be coloured %(color)s</p>
""" % results
Alternatively you might want to take a look at the HTMLgen module. It's
old, but still usable.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com
More information about the Python-list
mailing list