Python question

I have a python script running under mod_python/Apache2 that performs some
searching on a small database. That part works brilliantly. It displays the
data just fine but I am trying to display the results in a slightly less
rudimentary form than what python dumps out by default. Ideally I would like
a link or button to start a new query. Problem is I can’t seem to find a way
to have python generate a response page with embedded html or links. Anyone
have a link to a good resource for that?

Thanks.

On 22/08/2012 22:35, GofBorg wrote:[color=blue]

I have a python script running under mod_python/Apache2 that performs some
searching on a small database. That part works brilliantly. It displays the
data just fine but I am trying to display the results in a slightly less
rudimentary form than what python dumps out by default. Ideally I would like
a link or button to start a new query. Problem is I can’t seem to find a way
to have python generate a response page with embedded html or links. Anyone
have a link to a good resource for that?[/color]

Normally, you are expected to supply the HTML yourself, in the body -
apache expects to get back a preformatted html page, and if it gets
plain text then ok, it can handle that, but its not what it wants or is
expecting.

I would expect therefore you to use print lines to send something like:

Page Title

Page Heading

… python code goes here, until you get to an output loop, then per-row:

<Data column 2

… then exit the loop and do:

Column one header Column two header
Data column 1

Argument one:
Argument two:

that should give you a nicely formatted table, and a submission form.
you can prepopulate the value fields to give the last submitted input if
you want too.

obviously a real-world page will usually be more complex than that, but
given I don’t know your site, its hard to say what extra ornamentation
you need :slight_smile:

Thanks Dave,

That was what I was trying to do but didn’t understand how to
‘print’ the html codes. Makes sense now.