how to creating html files with python

Discussion in 'Python' started by krishnakant Mane, Oct 27, 2007.

  1. 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.
    krishnakant Mane, Oct 27, 2007
    #1
    1. Advertising

  2. 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
    Diez B. Roggisch, Oct 27, 2007
    #2
    1. Advertising

  3. On Oct 27, 12:12 pm, "krishnakant Mane" <>
    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
    George Sakkis, Oct 27, 2007
    #3
  4. On Oct 27, 12:02 pm, George Sakkis <> wrote:

    > 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
    BartlebyScrivener, Oct 27, 2007
    #4
  5. hi George,

    On 27/10/2007, George Sakkis <> wrote:
    > On Oct 27, 12:12 pm, "krishnakant Mane" <>
    > 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 <b> this 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.
    krishnakant Mane, Oct 27, 2007
    #5
  6. krishnakant Mane

    paul Guest

    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
    paul, Oct 28, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Justin Mencl
    Replies:
    3
    Views:
    2,040
    Sudsy
    Feb 8, 2004
  2. crazyprakash
    Replies:
    4
    Views:
    3,370
    adrian
    Oct 30, 2005
  3. Replies:
    4
    Views:
    950
    M.E.Farmer
    Feb 13, 2005
  4. srinivasan srinivas

    Python Modules To convert PDF files to HTML files

    srinivasan srinivas, Jul 30, 2008, in forum: Python
    Replies:
    0
    Views:
    378
    srinivasan srinivas
    Jul 30, 2008
  5. Replies:
    3
    Views:
    1,456
    Rolf Magnus
    Jan 18, 2009
Loading...

Share This Page