Returning a value from code string

Kirk McDonald mooquack at
Sat Jan 28 00:48:06 EST 2006

Steven D'Aprano wrote:
> On Fri, 27 Jan 2006 20:33:53 -0800, Kirk McDonald wrote:
>> Say I have a database containing chunks of Python code. I already 
>> have a way to easily load, edit, and save them.
> Why?

I am implementing an Everything Engine-like system (see
and in Python. (The original is in Perl, and by all
accounts is some pretty ugly code.) The Everything idiom is that
everything in the engine is a 'node.' A node is a discrete unit that can
be loaded from and saved to the database. A node can be asked to display
itself in the page, it has an owner (and users are themselves nodes),
and so on.

One kind of node is a Superdoc, which is a document that mixes HTML with
code. (I have simply implemented these as mod_python PSP documents,
which is all hunky-dory.) Superdocs comprise essentially all of the
important bits of the site. Another kind of node (I'm still deciding
whether to call them Codenodes or Opcodes or maybe Pynodes) is a chunk
of code that can be asked to run itself, and which can be edited, on the 
fly, from within the website. Thus, one can both alter the functionality 
of the site, and add functionality, from the site itself (so long as you 
have the user permissions to do so).

-Kirk McDonald

More information about the Python-list mailing list