[Zope3-checkins] CVS: Zope3/src/zodb - connection.py:1.7.4.6
Jeremy Hylton
jeremy@zope.com
Wed, 12 Mar 2003 18:22:10 -0500
Update of /cvs-repository/Zope3/src/zodb
In directory cvs.zope.org:/tmp/cvs-serv29525
Modified Files:
Tag: opaque-pickles-branch
connection.py
Log Message:
Fix invalidate() to always pass the version to the db.
Update TmpStore from changes made on trunk.
Remove some unused imports.
=== Zope3/src/zodb/connection.py 1.7.4.5 => 1.7.4.6 ===
--- Zope3/src/zodb/connection.py:1.7.4.5 Wed Mar 12 17:07:02 2003
+++ Zope3/src/zodb/connection.py Wed Mar 12 18:22:06 2003
@@ -37,19 +37,16 @@
$Id$
"""
-import cPickle
-from cStringIO import StringIO
import logging
import tempfile
import threading
-import time
from types import StringType, ClassType, TupleType
from zodb import interfaces
from zodb.conflict import ResolvedSerial
from zodb.export import ExportImport
from zodb.interfaces import *
-from zodb.serialize import ConnectionObjectReader, ObjectWriter
+from zodb.serialize import ConnectionObjectReader, ObjectWriter, findrefs
from zodb.storage.interfaces import IStorage
from zodb.utils import p64, u64, Set
@@ -535,14 +532,31 @@
self._tmp_undo.rollback()
self._conn._cache.invalidateMany(self._conn._modified)
+class UndoInfo:
+ """A helper class for rollback.
+
+ The class stores the state necessary for rolling back to a
+ particular time.
+ """
+
+ def __init__(self, store, pos, index):
+ self._store = store
+ self._pos = pos
+ self._index = index
+
+ def current(self, cur_store):
+ """Return true if the UndoInfo is for cur_store."""
+ return self._store is cur_store
+
+ def rollback(self):
+ self._store.rollback(self._pos, self._index)
+
+
class TmpStore:
"""A storage to support savepoints."""
_bver = ''
- # XXX This storage doesn't implementation the full API yet
- __implements__ = IStorage
-
def __init__(self, base_version):
self._transaction = None
if base_version:
@@ -559,10 +573,16 @@
self._db = None
def close(self):
+ # XXX Is this necessary?
self._file.close()
+ def getName(self):
+ return self._db.getName()
+
+ def getSize(self):
+ return self._pos
+
def load(self, oid, version):
- # XXX I don't think the version handling is correct here.
pos = self._index.get(oid, None)
if pos is None:
return self._storage.load(oid, self._bver)
@@ -579,10 +599,10 @@
def modifiedInVersion(self, oid):
if self._index.has_key(oid):
return self._bver
- return self._storage.modifiedInVersion(oid)
+ return self._db._storage.modifiedInVersion(oid)
def newObjectId(self):
- return self._storage.newObjectId()
+ return self._db._storage.newObjectId()
def registerDB(self, db):
self._db = db
@@ -591,6 +611,9 @@
def store(self, oid, serial, data, version, transaction):
if transaction is not self._transaction:
raise interfaces.StorageTransactionError(self, transaction)
+ # XXX Store this natively and get rid of the conditional split
+ if isinstance(data, tuple):
+ data, refs = data
self._file.seek(self._pos)
l = len(data)
if serial is None:
@@ -644,22 +667,3 @@
self._tpos = self._pos = pos
self._index = index
self._tindex.clear()
-
-class UndoInfo:
- """A helper class for rollback.
-
- The class stores the state necessary for rolling back to a
- particular time.
- """
-
- def __init__(self, store, pos, index):
- self._store = store
- self._pos = pos
- self._index = index
-
- def current(self, cur_store):
- """Return true if the UndoInfo is for cur_store."""
- return self._store is cur_store
-
- def rollback(self):
- self._store.rollback(self._pos, self._index)