More on web development

Tim Roberts timr at probo.com
Sat Jan 13 19:23:25 EST 2001


The recent thread on web development techniques and templating vs
Python-as-HTML has been very helpful.  I wonder if I might explore another
aspect of this, which actually relates more to using Python in larger
applications.

There are a number of ways to architect a Python-based web site with many
pages.  I have tended to build my site with one script per page, so that
the URL simply points to the .py file.  I'm now realizing this has a number
of disdvantages.  For one thing, it can be difficult to share global state.
I've tried to put common things, including instances of global data, into a
"common.py", but since common.py has to be imported into almost every file,
there seem to be multiple instance issues.

I'm wondering now if it would be better to have the whole site dispatched
by a single script, using the PATH_INFO part of the URL to identify a
command to be executed.  Does anyone have any feelings about this?

I'm also considering switching my global state from module-based to class
instance-based.  The biggest advantage to this, it seems to me, is that I
no longer need to worry about importing my common.py everywhere.  I can
pass the global class instance around and call the methods without the
import, and without worrying about nested import dependencies.

Any advice from the more experienced Python web developers?
--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list