[ZODB-Dev] Idiom question

Chris McDonough chrism@zope.com
Fri, 17 Aug 2001 15:55:26 -0400


In this case, it's useful to establish a different kind of Connection for
use by a particular DB instance, for example:

import ZODB
from ZODB.FileStorage import FileStorage
from DB import DB

s = FileStorage('whoo')
db = DB(s)
db.klass = LowConflictConnection
conn = db.conn()

When you do db.conn(), under the hood, your new LowConflictConnection class
is used instead of the stock Connection class.

----- Original Message -----
From: "Kent Hoxsey" <khoxsey@caspiannetworks.com>
To: <zodb-dev@zope.org>
Sent: Friday, August 17, 2001 2:23 PM
Subject: [ZODB-Dev] Idiom question


> There's a coding structure that I've seen a few times in some
> different parts of Zope, which I ran across again today in DB.py:
>
> class DB(UndoLogCompatible.UndoLogCompatible):
> # ...snip
> klass = Connection
> # ...more stuff snipped
> def open( self, version='', transaction=None, ...):
> #...snip
> c = self.klass(version, cache_size, etc.)
>
> I'm curious why Connection is aliased to klass, and then called as
> self.klass. What is gained over doing it this way:
>
> c = self.Connection(...)
>
> TIA.
>
> k1
>
> BTW, that's "idiom" not "idiot"... :-P
>
> _______________________________________________
> For more information about ZODB, see the ZODB Wiki:
> http://www.zope.org/Wikis/ZODB/
>
> ZODB-Dev mailing list  -  ZODB-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zodb-dev
>