HTML writer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Moosebumps

    HTML writer

    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


  • John Abel

    #2
    Re: HTML writer

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

    HTH

    J

    Moosebumps wrote:
    [color=blue]
    >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
    >
    >
    >
    >[/color]

    Comment

    • Walter Dörwald

      #3
      Re: HTML writer

      Moosebumps wrote:
      [color=blue]
      > 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.[/color]

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

      You can do more styling with CSS than you can do with HTML.
      [color=blue]
      > [...][/color]

      Bye,
      Walter Dörwald

      Comment

      • Leif B. Kristensen

        #4
        Re: HTML writer

        Moosebumps wrote:
        [color=blue]
        > 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?[/color]

        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.or g/>. 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,
        --
        Leif Biberg Kristensen

        Validare necesse est

        Comment

        • Moosebumps

          #5
          Re: HTML writer

          "Walter Dörwald" <walter@livingl ogic.de> wrote in message
          news:406D3C97.7 020006@livinglo gic.de...[color=blue]
          > Moosebumps wrote:
          >[color=green]
          > > 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[/color][/color]
          generate[color=blue][color=green]
          > > some internal reports on a web page.[/color]
          >
          > There are several possible HTML generators for Python:
          > HTMLgen http://starship.python.net/crew/frie...html/main.html
          > HyperText http://dustman.net/andy/python/HyperText/
          > XIST http://www.livinglogic.de/Python/xist/[/color]

          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


          Comment

          • Walter Dörwald

            #6
            Re: HTML writer

            Moosebumps wrote:
            [color=blue]
            > "Walter Dörwald" <walter@livingl ogic.de> wrote in message
            > news:406D3C97.7 020006@livinglo gic.de...
            >[color=green]
            >> [...]
            >>
            >>There are several possible HTML generators for Python:
            >>HTMLgen http://starship.python.net/crew/frie...html/main.html
            >>HyperText http://dustman.net/andy/python/HyperText/
            >>XIST http://www.livinglogic.de/Python/xist/[/color]
            >
            >
            > 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?[/color]

            Each of them requires you to know what the HTML tags mean.
            [color=blue]
            > 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.[/color]

            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/in...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

            Comment

            • Tuure Laurinolli

              #7
              Re: HTML writer

              Moosebumps wrote:
              [color=blue]
              > 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.[/color]

              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

              Comment

              • Moosebumps

                #8
                Re: HTML writer

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

                MB

                "Tuure Laurinolli" <tuure@laurinol li.net> wrote in message
                news:c4mh8n$bmv $1@plaza.suomi. net...[color=blue]
                > Moosebumps wrote:
                >[color=green]
                > > That is, I would not like any specific HTML tags anywhere in my own[/color][/color]
                code,[color=blue][color=green]
                > > 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.[/color]
                >
                > 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[/color]


                Comment

                • has

                  #9
                  Re: HTML writer

                  "Moosebumps " <moosebumps@moo sebumps.com> wrote in message news:<yL9bc.452 02$wH3.33614@ne wssvr25.news.pr odigy.com>...[color=blue]
                  > 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.[/color]

                  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.virgi n.net/hamish.sanderso n/htmltemplate.ht ml>.
                  Compiles HTML templates to a simple Python object model than can be
                  manipulated programmaticall y. 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/Nevow2004Tutori al.html>
                  for an introduction.

                  [color=blue]
                  > 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?[/color]

                  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 programmaticall y -
                  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.

                  [color=blue]
                  > I am an experienced
                  > programming, but I don't know that much about all the alphabet soup that is
                  > web programming.[/color]

                  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.or g/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

                  Comment

                  Working...