append to non-existing list

B

bonono

Yves said:
Which raises another question... :)

Is there a possibility to bring together apache and python in a way that
I can embed python into html?
What do you mean ?
Or even, write a smallish webserver in python (using twisted maybe)
whose only purpose is to serve pages and execute the embedded code...?
My favorite is TurboGears, a collection of modules and glue that brings
together HTTP server(cherrypy), template(Kid) and SQL object
store(SQLObject) that can do serious web developement yet don't need to
read a book before starting.

If you just need the server, cherrypy is pretty good and simple to
start.
 
Y

Yves Glodt

What do you mean ?

I need this (invalid example-html follows):

<html>
<h1>title of page</h1>

<?py

import time

print "<p>Hello, today is: %s</p>" % (time.ctime())

?>

</html>


Should that not be fairly easy to to, even from scratch, with the
httplib module...?

The advantage would be that I could write a webinterface for my database
and reuse the classes I wrote for the command line app.
My favorite is TurboGears, a collection of modules and glue that brings
together HTTP server(cherrypy), template(Kid) and SQL object
store(SQLObject) that can do serious web developement yet don't need to
read a book before starting.

If you just need the server, cherrypy is pretty good and simple to
start.

Ok gonna look into that,

regards,
Yves
 
B

bonono

Yves said:
I need this (invalid example-html follows):

<html>
<h1>title of page</h1>

<?py

import time

print "<p>Hello, today is: %s</p>" % (time.ctime())

?>

</html>
Cheetah template ?

But I like Kid better as I don't want python in HTML, Kid IMO strikes
the balance between python feature and XHTML so the template is still
readable by any XHTML editors.
 
M

Mike Meyer

Yves Glodt said:
Which raises another question... :)

Is there a possibility to bring together apache and python in a way
that I can embed python into html?

Lots of ways. Most of them aren't really Python, but look a lot like
it.

PSP is most like PHP/ASP/etc., and I believe current mod_python's come
with a PSP processor. Be warned that there's more than one thing
floating around by the name Python Server Pages, and they aren't
completely compatible.

Personally, I prefer Cheetah for this, for three reasons:

1) Cheetah doesn't use X/HTML-like syntax for it's tags, so they don't
interfere with my intelligent X/HTML tools.

2) Cheetah can be used for things other than X/HTML, so you get a
twofer on tools. For my last project, I created the Makefile from a
Cheetah template.

3) Cheetah templates are Classes, so you inherit from them. The same
last project created a top-level template that did the site-wide
banner/nav/etc things, and defined abstracd methods for the
title/content. Pages inherited from that (or in some cases from a
subclass of that) and defined concrete versions of the abstrat
methods. Cheetah templates can inherit from Python classes (which I've
found useful), and Python classes can inherit from Cheetah templates
(which sounds useful, but I haven't used it yet).
Or even, write a smallish webserver in python (using twisted maybe)
whose only purpose is to serve pages and execute the embedded code...?

Well, you could always use the CGIHttpServer module that's in the
standard library for this. Cheetah templates can be tested outside the
sever environment, so you don't need a server to execute the embedded
code.

<mike
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,270
Messages
2,571,351
Members
48,036
Latest member
nickwillsonn

Latest Threads

Top