Separation of Code in CGI App

Sybren Stuvel sybrenUSE at YOURthirdtower.com.imagination
Fri Jul 22 14:15:49 CEST 2005


Rob Cowie enlightened us with:
> I need to create a planner/calendar system using python cgi scripts.
> It is my first CGI app (beyond a few tutorial examples).

Are you sure you want to use CGI? I'd go for mod_python instead if at
all possible, since that'll give you a much better performance.

> To do this, do I just create each of these classes in one,
> monolithic .cgi file?

Please don't. It's much better to put things into modules, and import
them when needed.

> 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.

Why that difficult? What's wrong with just doing "from htmlgenerator
import pagexy"?

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

Check out http://www.unrealtower.org/mycheetah

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
                                             Frank Zappa



More information about the Python-list mailing list