[Zodb-checkins] SVN: ZODB/trunk/src/ZODB/DB.py Renamed DB.open to connection

Jim Fulton jim at zope.com
Thu Apr 30 07:43:43 EDT 2009


Log message for revision 99601:
  Renamed DB.open to connection
  
  Added an option to disallow cross-database references.
  

Changed:
  U   ZODB/trunk/src/ZODB/DB.py

-=-
Modified: ZODB/trunk/src/ZODB/DB.py
===================================================================
--- ZODB/trunk/src/ZODB/DB.py	2009-04-30 11:43:41 UTC (rev 99600)
+++ ZODB/trunk/src/ZODB/DB.py	2009-04-30 11:43:43 UTC (rev 99601)
@@ -331,20 +331,6 @@
     return before
 
 
-class Methods(object):
-
-    def __init__(self, name, ifunc, cfunc=None):
-        self.__name__ = name
-        self.im_func = ifunc
-        self.cm_func = cfunc
-
-    def __get__(self, inst, class_):
-        if inst is None:
-            if self.cm_func is None:
-                raise AttributeError("Only in instances", self.__name__)
-            return self.cm_func.__get__(class_, type(class_))
-        return self.im_func.__get__(inst, class_)
-
 class DB(object):
     """The Object Database
     -------------------
@@ -401,7 +387,7 @@
                  historical_timeout=300,
                  database_name='unnamed',
                  databases=None,
-                 ):
+                 xrefs=True):
         """Create an object database.
 
         :Parameters:
@@ -419,6 +405,8 @@
             the historical connection.
           - `historical_timeout`: minimum number of seconds that
             an unused historical connection will be kept, or None.
+          - `xrefs` - Boolian flag indicating whether implicit cross-database
+            references are allowed
         """
         if isinstance(storage, basestring):
             from ZODB import FileStorage
@@ -490,6 +478,7 @@
             raise ValueError("database_name %r already in databases" %
                              database_name)
         databases[database_name] = self
+        self.xrefs = xrefs
 
         self._setupUndoMethods()
         self.history = storage.history
@@ -779,14 +768,6 @@
         finally:
             self._r()
 
-    def class_open(class_, *args, **kw):
-        db = class_(*args, **kw)
-        conn = db.open()
-        conn.onCloseCallback(db.close)
-        return conn
-
-    open = Methods('open', open, class_open)
-
     def connectionDebugInfo(self):
         result = []
         t = time.time()
@@ -1010,3 +991,9 @@
         # XXX see XXX in ResourceManager
         tid, oids = self._db.storage.undo(self._tid, t)
         self._db.invalidate(tid, dict.fromkeys(oids, 1))
+
+def connection(*args, **kw):
+    db = DB(*args, **kw)
+    conn = db.open()
+    conn.onCloseCallback(db.close)
+    return conn



More information about the Zodb-checkins mailing list