Commit 41c20bde authored by Dmitry Vasiliev's avatar Dmitry Vasiliev

Now use ZODB.utils.z64 instead of '\0\0\0\0\0\0\0\0' where appropriate

parent 402ea2f9
...@@ -25,6 +25,7 @@ import POSException ...@@ -25,6 +25,7 @@ import POSException
from persistent.TimeStamp import TimeStamp from persistent.TimeStamp import TimeStamp
from ZODB import POSException, utils from ZODB import POSException, utils
from ZODB.utils import z64
from ZODB.UndoLogCompatible import UndoLogCompatible from ZODB.UndoLogCompatible import UndoLogCompatible
log = logging.getLogger("ZODB.BaseStorage") log = logging.getLogger("ZODB.BaseStorage")
...@@ -98,7 +99,7 @@ class BaseStorage(UndoLogCompatible): ...@@ -98,7 +99,7 @@ class BaseStorage(UndoLogCompatible):
t=self._ts=apply(TimeStamp,(time.gmtime(t)[:5]+(t%60,))) t=self._ts=apply(TimeStamp,(time.gmtime(t)[:5]+(t%60,)))
self._tid = `t` self._tid = `t`
if base is None: if base is None:
self._oid='\0\0\0\0\0\0\0\0' self._oid=z64
else: else:
self._oid=base._oid self._oid=base._oid
......
...@@ -22,6 +22,7 @@ import warnings ...@@ -22,6 +22,7 @@ import warnings
import logging import logging
from ZODB.broken import find_global from ZODB.broken import find_global
from ZODB.utils import z64
from ZODB.Connection import Connection from ZODB.Connection import Connection
from ZODB.serialize import referencesf from ZODB.serialize import referencesf
...@@ -124,7 +125,7 @@ class DB(object): ...@@ -124,7 +125,7 @@ class DB(object):
if not hasattr(storage,'tpc_vote'): if not hasattr(storage,'tpc_vote'):
storage.tpc_vote = lambda *args: None storage.tpc_vote = lambda *args: None
try: try:
storage.load('\0\0\0\0\0\0\0\0','') storage.load(z64,'')
except KeyError: except KeyError:
# Create the database's root in the storage if it doesn't exist # Create the database's root in the storage if it doesn't exist
from persistent.mapping import PersistentMapping from persistent.mapping import PersistentMapping
...@@ -138,7 +139,7 @@ class DB(object): ...@@ -138,7 +139,7 @@ class DB(object):
t = transaction.Transaction() t = transaction.Transaction()
t.description = 'initial database creation' t.description = 'initial database creation'
storage.tpc_begin(t) storage.tpc_begin(t)
storage.store('\0\0\0\0\0\0\0\0', None, file.getvalue(), '', t) storage.store(z64, None, file.getvalue(), '', t)
storage.tpc_vote(t) storage.tpc_vote(t)
storage.tpc_finish(t) storage.tpc_finish(t)
......
...@@ -82,6 +82,7 @@ and call it to monitor the storage. ...@@ -82,6 +82,7 @@ and call it to monitor the storage.
import base64, time, string import base64, time, string
from ZODB import POSException, BaseStorage, utils from ZODB import POSException, BaseStorage, utils
from ZODB.utils import z64
from persistent.TimeStamp import TimeStamp from persistent.TimeStamp import TimeStamp
from cPickle import loads from cPickle import loads
from BTrees import OOBTree from BTrees import OOBTree
...@@ -409,7 +410,7 @@ class DemoStorage(BaseStorage.BaseStorage): ...@@ -409,7 +410,7 @@ class DemoStorage(BaseStorage.BaseStorage):
# Now build an index of *only* those objects reachable # Now build an index of *only* those objects reachable
# from the root. # from the root.
rootl = ['\0\0\0\0\0\0\0\0'] rootl = [z64]
pindex = {} pindex = {}
while rootl: while rootl:
oid = rootl.pop() oid = rootl.pop()
......
...@@ -21,7 +21,7 @@ It is meant to illustrate the simplest possible storage. ...@@ -21,7 +21,7 @@ It is meant to illustrate the simplest possible storage.
The Mapping storage uses a single data structure to map object ids to data. The Mapping storage uses a single data structure to map object ids to data.
""" """
from ZODB import utils from ZODB.utils import u64, z64
from ZODB import BaseStorage from ZODB import BaseStorage
from ZODB import POSException from ZODB import POSException
from persistent.TimeStamp import TimeStamp from persistent.TimeStamp import TimeStamp
...@@ -115,7 +115,7 @@ class MappingStorage(BaseStorage.BaseStorage): ...@@ -115,7 +115,7 @@ class MappingStorage(BaseStorage.BaseStorage):
if not self._index: if not self._index:
return return
# Build an index of *only* those objects reachable from the root. # Build an index of *only* those objects reachable from the root.
rootl = ['\0\0\0\0\0\0\0\0'] rootl = [z64]
pindex = {} pindex = {}
while rootl: while rootl:
oid = rootl.pop() oid = rootl.pop()
...@@ -144,6 +144,6 @@ class MappingStorage(BaseStorage.BaseStorage): ...@@ -144,6 +144,6 @@ class MappingStorage(BaseStorage.BaseStorage):
for oid in keys: for oid in keys:
r = self._index[oid] r = self._index[oid]
o.append(' %s: %s, %s' % o.append(' %s: %s, %s' %
(utils.u64(oid),TimeStamp(r[:8]),`r[8:]`)) (u64(oid),TimeStamp(r[:8]),`r[8:]`))
return '\n'.join(o) return '\n'.join(o)
...@@ -19,6 +19,8 @@ objects like hit counters that don't need or want to participate ...@@ -19,6 +19,8 @@ objects like hit counters that don't need or want to participate
in undo or versions. in undo or versions.
""" """
from ZODB.utils import z64
from MappingStorage import MappingStorage from MappingStorage import MappingStorage
from BaseStorage import BaseStorage from BaseStorage import BaseStorage
import anydbm, os import anydbm, os
...@@ -56,7 +58,7 @@ class gdbmStorage(anydbmStorage): ...@@ -56,7 +58,7 @@ class gdbmStorage(anydbmStorage):
self._index=index=gdbm.open(filename, flag[:1]+'f', mode) self._index=index=gdbm.open(filename, flag[:1]+'f', mode)
self._tindex=[] self._tindex=[]
m='\0\0\0\0\0\0\0\0' m=z64
oid=index.firstkey() oid=index.firstkey()
while oid != None: while oid != None:
m=max(m, oid) m=max(m, oid)
...@@ -76,7 +78,7 @@ class gdbmStorage(anydbmStorage): ...@@ -76,7 +78,7 @@ class gdbmStorage(anydbmStorage):
# Build an index of *only* those objects reachable # Build an index of *only* those objects reachable
# from the root. # from the root.
index=self._index index=self._index
rootl=['\0\0\0\0\0\0\0\0'] rootl=[z64]
pop=rootl.pop pop=rootl.pop
pindex={} pindex={}
referenced=pindex.has_key referenced=pindex.has_key
......
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