471,305 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,305 software developers and data experts.

how to creating html files with python

hello,
I have one strange requirement,
I need to create html files through python and add some data from the database.
it is a GUI based application developed in WX python.
and the reports need to come out in html for some strange reason which
is off topic to discuss here.
but the point is that how do I do it?
should I create a normal file object and write the html with the data
into it or are there some modules to do it?
regards,
Krishnakant.
Oct 27 '07 #1
5 1460
krishnakant Mane schrieb:
hello,
I have one strange requirement,
I need to create html files through python and add some data from the database.
it is a GUI based application developed in WX python.
and the reports need to come out in html for some strange reason which
is off topic to discuss here.
but the point is that how do I do it?
should I create a normal file object and write the html with the data
Essentially, yes.
into it or are there some modules to do it?

There are a bazillion templating systems out there. Beginning with
python's own string interpolation, to

KID, genshi, Mako, tenjin, cheeta, ... <continue>

Search this NG for python templating engines, and you'd be overwhelmed
by the answers.

Happy chosing your evil,

Diez
Oct 27 '07 #2
On Oct 27, 12:12 pm, "krishnakant Mane" <researchb...@gmail.com>
wrote:
I have one strange requirement,
I need to create html files through python and add some data from the database.
The only strange thing here is that you think this is a strange
requirement :) This is quite typical, and practically required for web
development. As Diez pointed out, your main problem will be which of
the dozen or so template packages to pick. Depending on your criteria
(expressive power, syntax close to python, performance, stability
etc.) you may narrow it down to a handful.

George

Oct 27 '07 #3
On Oct 27, 12:02 pm, George Sakkis <george.sak...@gmail.comwrote:
The only strange thing here is that you think this is a strange
requirement :) This is quite typical, and practically required for web
development.
I was wondering about this myself the other day. Suppose you wanted to
get by on the cheap without setting up a whole new Joomla or WordPress
installation for another smallish blog or website where you are the
only poster, and all you need is simple CMS.

How hard would it be to create, say, a calendar of events, or news
postings using MySQL and Python and HTML. Create the page on your
local machine using Python templating, and then just post the HTML
code daily?

I'm a rank amateur, but was wondering if this is silly and making
work, or if one of those templating systems you all are mentioning
would work for simple CMS and calendaring?

Thanks,

rd
Oct 27 '07 #4
hi George,

On 27/10/2007, George Sakkis <ge***********@gmail.comwrote:
On Oct 27, 12:12 pm, "krishnakant Mane" <researchb...@gmail.com>
wrote:
I have one strange requirement,
I need to create html files through python and add some data from the
database.

The only strange thing here is that you think this is a strange
requirement :) This is quite typical, and practically required for web
development. As Diez pointed out, your main problem will be which of
the dozen or so template packages to pick. Depending on your criteria
I am finding it difficult to choose.
my only requirement is to create an htmo file with normal html taggs
but the values come from a database connection.
so I want to get rid of doing the entire concatination right from
start till end. I don't mind opening a file and doing file.write()
but it will be nice of some module to help me get the data
concatinated with taggs and rather even better if I can do complex
things like creating an html table whos rows contain data coming from
a result set.
here I would like to have the tagging more like functions, some thing
like report.bold("this must be bold ") and this function to return a
line with the bolded html which looks in the file as <bthis must be
bold </b>
so instead of I doing the concatination myself, python makes it easy.
and I will have lot of complex tables etc to do like this.
so please help me choose one.
regards,
Krishnakant.
Oct 27 '07 #5
krishnakant Mane schrieb:
[snip]
so instead of I doing the concatination myself, python makes it easy.
and I will have lot of complex tables etc to do like this.
so please help me choose one.
Did you actually looked for a template language as suggested here?
Now to make your life easier: If you like XML, use genshi. If you plan
to generate something else than HTML, use cheetah. Use google or
whatever search engine you prefer to find those packages.

cheers
Paul

Oct 27 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Adam T. Gautier | last post: by
4 posts views Thread by sepgy | last post: by
4 posts views Thread by Edvard Majakari | last post: by
10 posts views Thread by John Salerno | last post: by
2 posts views Thread by macedo.silva | last post: by
3 posts views Thread by jd | last post: by
7 posts views Thread by DanielJohnson | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.