SVN: ZODB/trunk/src/ DemoStorages didn't close their changes databases when they were

Jim Fulton <[email protected]>
Newsgroups gmane.comp.python.zope.zodb.cvs
Message-ID <20100710192113.EABEB941B8__6263.85201835564$1278789677$gmane$org@cvs.zope.org>
Log message for revision 114544:
  DemoStorages didn't close their changes databases when they were
  created temporarily (not passed to the constructor).
  

Changed:
  U   ZODB/trunk/src/CHANGES.txt
  U   ZODB/trunk/src/ZODB/DemoStorage.py
  U   ZODB/trunk/src/ZODB/DemoStorage.test

-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt	2010-07-10 19:12:23 UTC (rev 114543)
+++ ZODB/trunk/src/CHANGES.txt	2010-07-10 19:21:13 UTC (rev 114544)
@@ -8,6 +8,10 @@
 Bugs fixed
 ----------
 
+- When a demo storage push method was used to create a new demo
+  storage and the new storage was closed, the original was
+  (incorrectly) closed.
+
 - DemoStorages didn't close their changes databases when they were
   created temporarily (not passed to the constructor).
 

Modified: ZODB/trunk/src/ZODB/DemoStorage.py
===================================================================
--- ZODB/trunk/src/ZODB/DemoStorage.py	2010-07-10 19:12:23 UTC (rev 114543)
+++ ZODB/trunk/src/ZODB/DemoStorage.py	2010-07-10 19:21:13 UTC (rev 114544)
@@ -94,7 +94,12 @@
         self.base.cleanup()
         self.changes.cleanup()
 
+    __opened = True
+    def opened(self):
+        return self.__opened
+
     def close(self):
+        self.__opened = False
         if self.close_base_on_close:
             self.base.close()
         if self.close_changes_on_close:
@@ -253,7 +258,8 @@
         return self.base
 
     def push(self, changes=None):
-        return self.__class__(base=self, changes=changes)
+        return self.__class__(base=self, changes=changes,
+                              close_base_on_close=False)
 
     def store(self, oid, serial, data, version, transaction):
         assert version=='', "versions aren't supported"

Modified: ZODB/trunk/src/ZODB/DemoStorage.test
===================================================================
--- ZODB/trunk/src/ZODB/DemoStorage.test	2010-07-10 19:12:23 UTC (rev 114543)
+++ ZODB/trunk/src/ZODB/DemoStorage.test	2010-07-10 19:21:13 UTC (rev 114544)
@@ -185,7 +185,12 @@
     >>> changes.opened()
     False
 
+If storage returned by push is closed, the original storage isn't:
 
+    >>> demo3.push().close()
+    >>> demo2.opened()
+    True
+
 Blob Support
 ============
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.