cgi, reusing html. common problem?
John M. Gabriele
john_sips_teaz at yahooz.com
Thu Sep 1 23:12:05 EDT 2005
On Thu, 01 Sep 2005 20:57:56 -0500, Steve Holden wrote:
> John M. Gabriele wrote:
>> [snip]
>>
>> Is that how it's usually done? If not, what *is* the
>> usual way of handling this?
>>
> There are a million ways to solve this particular problem, despite
> Python's "TSBOAPOOOWTDI" (see "import this") philosophy (because the
> philosophy is addressing primitive programming rather than application
> frameworks).
Yes. :)
> You could do something as simple as writing a module "webPage" that
> defines a function page(path, content) that does something along the
> lines of:
>
> def page(path, content):
> return """\
> <html>
> <title>If you want titles, add another argument</title>
> </head>
> <body>
> <this would be code to build a nav bar, omitting a hypertext link for
> the path given as an argument - I'm just ignoring it in this example>
> %s
> </body>
> </html>
> """ % content
Ah yes, I see. If the content is completely static, you
can use a text file (html fragment) and just read it and
paste it in, but for fragments that are *mostly* static,
I really like that idea to use a module as you suggest.
> [snip]
>
> Hope this gives you a few ideas. This problem has been considered by
> many people, but clearly no outstanding solution has yet been devised,
> otherwise we'd all be using it.
>
> regards
> Steve
Thanks Steve!
---John
--
--- if contacting via email, remove zees ---
More information about the Python-list
mailing list