Commit 0d089b4e authored by Jason Madden's avatar Jason Madden

Make TmpStore implement its own getSize

This is consistent with its __len__ and provides a better figure for existing logging.

Fixes #282
parent 2f8cc67a
...@@ -24,6 +24,11 @@ ...@@ -24,6 +24,11 @@
holds bytes as they are stored (i.e. no deserialization happens). holds bytes as they are stored (i.e. no deserialization happens).
See `issue 207 <https://github.com/zopefoundation/ZODB/pull/207>`_. See `issue 207 <https://github.com/zopefoundation/ZODB/pull/207>`_.
- Make a connection's savepoint storage implement its own
(approximate) ``getSize`` method instead of relying on the original
storage. Previously, this produced confusing DEBUG logging. See
`issue 282 <https://github.com/zopefoundation/ZODB/issues/282>`_.
5.5.1 (2018-10-25) 5.5.1 (2018-10-25)
================== ==================
......
...@@ -1135,21 +1135,23 @@ class TmpStore(object): ...@@ -1135,21 +1135,23 @@ class TmpStore(object):
def __init__(self, storage): def __init__(self, storage):
self._storage = storage self._storage = storage
for method in ( for method in (
'getName', 'new_oid', 'getSize', 'sortKey', 'getName', 'new_oid', 'sortKey',
'isReadOnly' 'isReadOnly'
): ):
setattr(self, method, getattr(storage, method)) setattr(self, method, getattr(storage, method))
self._file = tempfile.TemporaryFile(prefix='TmpStore') self._file = tempfile.TemporaryFile(prefix='TmpStore')
# position: current file position # position: current file position. If objects are only stored
# _tpos: file position at last commit point # once, this is approximately the byte size of object data stored.
self.position = 0 self.position = 0
# index: map oid to pos of last committed version # index: map oid to pos of last committed version
self.index = {} self.index = {}
self.creating = {} self.creating = {}
self._blob_dir = None self._blob_dir = None
def getSize(self):
return self.position
def __len__(self): def __len__(self):
return len(self.index) return len(self.index)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment