Web app scope question

fee fee at fee.com
Thu Sep 9 11:51:12 EDT 2004


I'm using mod_python to write a web app.  I always load
one file, index.py which generates the skeleton of the page,
while functions and objects from other modules are used to
produce the content based on the current state of the app.

Some of the data, such as a registrants id number, shopping
cart data, current app page/state etc... are needed by almost
every module that provides content for the page.  In my old
PHP app, these were simply global vars, which aside from its
reputation as bad form worked fairly well.

Now, I find myself stuffing all of these things into an object,
and passing it around every where, as an argument to each
function, or as a constructor argument.  The other alternative
that I have considered is to make a 'borg' class, whose
attributes always remain the same across instantiations.

I just wondered about the experience of the list regarding
sets of data that really need to be visible to most of the
modules in the app.

Thanks,

Toby



More information about the Python-list mailing list