Separation of Code in CGI App

Rob Cowie cowie.rob at gmail.com
Fri Jul 22 14:02:30 CEST 2005


Hi,

I need to create a planner/calendar system using python cgi scripts. It
is my first CGI app (beyond a few tutorial examples).

I wish to separate the code according to function. For instance, the
code to handle the DB connection, SQL querying, HTML form variable
retrieval, rendering of HTML via some sort of template system etc. Each
will be a class instantiated when the CGI app is called.

To do this, do I just create each of these classes in one, monolithic
.cgi file? or is it possible to separate these out into different
scripts and have a 'controller' script call them and pass the relevant
parameters/data? I guess I could also store the python code in text
files and use the 'execfile()' function, although it seems to me that
would be an uneccasary performance hit.

If that is possible, is that the right way to go? If not, suggestions
would be gratefully recieved!




More information about the Python-list mailing list