An idea - request for comments

Ian Clarke I.Clarke at
Tue Aug 3 10:05:47 CEST 1999

I am presently working on a CGI based system in Python, and the
experience gave me an idea for a simple Python program, I would
appreciate any comments (such as "don't bother, it's been done" or
"sure, I have loads of spare time, I will do it and release it under the

It is to create a Python web server which automatically parses embedded
Python in HTML (there is a Perl extension that does this too).  So, for
example, the following HTML code:

  n = 10
  print n*2
  print n*3

Would output:

Page Title: 20

Internally, operation of the system would be simple.  The HTML page with
embedded python would first be converted to a python file (by having a
print statement output the HTML between the embedded python), this could
then be compiled for efficiency as when normal files are executed.  The
web server would then parse these files when requested (using an
appropriately neat method to allow access to CGI variables and Cookies
and the like from within the embedded HTML).  This would lead to a speed
improvement in that the Python interpreter need not be launched every
time.  The efficiency could be further improved by caching the compiled
python files in memory.

Cool facilities could also be implemented which sit ontop of the base
CGI and Cookie layers to emulate a "per-user" memory.  This would allow
a dictionary to be stored only to be retrieved the next time this user
accesses the site (this would be achieved using cookies and storing
information locally with a cookie-style self destruct).  Similarly, a
"per-session" memory could be implemented, making it much easier to
transfer information (such as a username and password) from one page to
the next.

Before people start pointing it out, I know this isn't the most original
idea in the world, but if it hasn't been done for Python (and I can't
find anything similar) then it is high time that it was.

I look forward to reading your comments,


More information about the Python-list mailing list