A question of style
Roy Smith
roy at popmail.med.nyu.edu
Tue Aug 3 15:45:58 EDT 1999
I'm using BaseHTTPServer. I need to maintain a long-lived database
connection (using oracledb), and the only persistant object is my server,
so the db connection is stored there.
I've got a class for each type of page that gets displayed, with widgets
on each page that need to access the database. Thus, I end up with stuff
like:
self.page.handler.server.db.cursor()
inside my widget class methods. This works, but it's kind of messy. I'm
thinking of giving my base widget class a cursor method, which looks like:
def cursor(self):
return self.page.handler.server.db.cursor()
and then I can just do self.cursor() inside my widgets.
I can't think of any particularly compelling technical reasons why that's
a good or bad thing. Seems more like a matter of style than anything
else. Comments?
--
Roy Smith <roy at popmail.med.nyu.edu>
New York University School of Medicine
More information about the Python-list
mailing list