[Zodb-checkins] CVS: StandaloneZODB/ZODB - DB.py:1.38
Brian Lloyd
brian@zope.com
Wed, 9 Jan 2002 14:15:32 -0500
Update of /cvs-repository/StandaloneZODB/ZODB
In directory cvs.zope.org:/tmp/cvs-serv839
Modified Files:
DB.py
Log Message:
Fixed a lost update from the __module__ merge.
=== StandaloneZODB/ZODB/DB.py 1.37 => 1.38 ===
-#
+#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -72,15 +72,20 @@
self._storage=storage
storage.registerDB(self, None)
if not hasattr(storage,'tpc_vote'): storage.tpc_vote=lambda *args: None
- try: storage.load('\0\0\0\0\0\0\0\0','')
- except:
+ try:
+ storage.load('\0\0\0\0\0\0\0\0','')
+ except KeyError:
+ # Create the database's root in the storage if it doesn't exist
import PersistentMapping
- file=cStringIO.StringIO()
- p=cPickle.Pickler(file,1)
- p.dump((PersistentMapping.PersistentMapping,None))
- p.dump({'_container': {}})
- t=Transaction()
- t.description='initial database creation'
+ root = PersistentMapping.PersistentMapping()
+ # Manually create a pickle for the root to put in the storage.
+ # The pickle must be in the special ZODB format.
+ file = cStringIO.StringIO()
+ p = cPickle.Pickler(file, 1)
+ p.dump((root.__class__, None))
+ p.dump(root.__getstate__())
+ t = Transaction()
+ t.description = 'initial database creation'
storage.tpc_begin(t)
storage.store('\0\0\0\0\0\0\0\0', None, file.getvalue(), '', t)
storage.tpc_vote(t)
@@ -182,7 +187,7 @@
module = getattr(ob.__class__, '__module__', '')
module = module and '%s.' % module or ''
-
+
detail.append({
'conn_no': cn,
'oid': oid,