473,287 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 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 1538
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Adam T. Gautier | last post by:
Greetings, I am trying to create a python module for a series of class files that because of their size I have divided into multiple files. class Foo --> foo.py class Boo --> boo.py I have...
4
by: sepgy | last post by:
Can anyone help me to use a python to create an HTML photo gallery generator. When it's finished, it will be able find all the picture files (i.e. .jpg, .gif. .png files) in any given folder on the...
4
by: Edvard Majakari | last post by:
Greetings, fellow Pythonistas! I'm about to create three modules. As an avid TDD fan I'd like to create typical 'use-cases' for each of these modules. One of them is rather large, and I wondered...
2
by: rdsteph | last post by:
Python411 is a series of podcasts about Python, aimed at hobbyists and others who are learning Python. Each episode focuses on one aspect of learning Python, or one kind of Python programming, and...
13
by: DH | last post by:
Hi, I'm trying to strip the html and other useless junk from a html page.. Id like to create something like an automated text editor, where it takes the keywords from a txt file and removes them...
10
by: John Salerno | last post by:
Ok, this is completely unnecessary so I don't intend to get into stuff that's beyond my skill, but I'm wondering how simple it would be to use Python to create a server that runs on my computer so...
2
by: macedo.silva | last post by:
Hi, I would like to request your attention for this very specific issue: I have several classes in Python, and now I want simply re-use it, in other language. The closest to solution I...
3
by: jd | last post by:
I'd like to create a program that takes files with "jsp-like" markup and processes the embedded code (which would be python) to produce the output file. There would be two kinds of sections in the...
7
by: DanielJohnson | last post by:
I have a small project which has around 10 .py files and I run this project using command line arguments. I have to distribute this project to somebody. I was wondering how can I make an...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.