A question of style
Thomas A. Bryan
tbryan at arlut.utexas.edu
Tue Aug 3 21:17:21 EDT 1999
Roy Smith wrote:
> 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()
Either that, or you could just make an alias like
dbconn = self.page.handler.server.db
and use it like this
dbconn.cursor()
I personally like the cursor, but I thought I'd mention
the aliasing technique in case you had forgotten about it.
More information about the Python-list
mailing list