[Zodb-checkins] CVS: Zope3/src/zodb/storage - base.py:1.5.2.3 file.py:1.5.2.5
Jeremy Hylton
jeremy@zope.com
Fri, 24 Jan 2003 17:27:34 -0500
Update of /cvs-repository/Zope3/src/zodb/storage
In directory cvs.zope.org:/tmp/cvs-serv23645/storage
Modified Files:
Tag: new-pickle-branch
base.py file.py
Log Message:
Call YAGNI on storing release information in the database version.
The database version is a simple magic number that needs to get
changed when the database record (aka pickle) format changes.
=== Zope3/src/zodb/storage/base.py 1.5.2.2 => 1.5.2.3 ===
--- Zope3/src/zodb/storage/base.py:1.5.2.2 Thu Jan 23 13:54:01 2003
+++ Zope3/src/zodb/storage/base.py Fri Jan 24 17:27:30 2003
@@ -49,27 +49,6 @@
GBYTES = 1024 * 1024 * 1000
JOIN_TIME = 10
-_release_status = {"alpha": 0xA,
- "beta": 0xB,
- "gamma": 0xC,
- "final": 0xF}
-
-def encode_version(vt):
- """Encode a version-tuple as a 4-byte string."""
- major, minor, micro, level, serial = vt
- level = _release_status[level]
- return struct.pack(">BBBB", major, minor, micro, (level << 4) | serial)
-
-def decode_version(vs):
- """Decode a 4-byte version string into a tuple."""
- major, minor, micro, last = struct.unpack(">BBBB", vs)
- serial = last & 0x0F
- _level = last >> 4
- for k, v in _release_status.items():
- if v == _level:
- level = k
- return major, minor, micro, level, serial
-
class PackStop(Exception):
"""Escape hatch for pack operations."""
@@ -674,14 +653,10 @@
self._info.put('dbversion', vstr, txn=txn)
def setVersion(self, version):
- encvers = encode_version(version)
- self._withtxn(self._setVersion, encvers)
+ self._withtxn(self._setVersion, version)
def getVersion(self):
- version = self._info.get('dbversion')
- if version is not None:
- return decode_version(version)
- return version
+ return self._info.get('dbversion')
def close(self):
"""Close the storage.
=== Zope3/src/zodb/storage/file.py 1.5.2.4 => 1.5.2.5 ===
--- Zope3/src/zodb/storage/file.py:1.5.2.4 Thu Jan 23 13:40:47 2003
+++ Zope3/src/zodb/storage/file.py Fri Jan 24 17:27:30 2003
@@ -144,7 +144,6 @@
fsync = None
import zodb.db
-from zodb.storage.base import encode_version, decode_version
from zodb.storage.base import BaseStorage, TransactionRecord, DataRecord
from zodb import conflict
from zodb import interfaces
@@ -393,7 +392,7 @@
return pos, maxoid, ltid
_metadata_size = 1024
- _format_version = "01"
+ _format_version = "41"
def _read_metadata(self):
# Read the 1K metadata block at the beginning of the storage.
@@ -406,7 +405,7 @@
raise FileStorageFormatError(self._file.name)
ver = self._file.read(4)
if ver != "\0" * 4:
- self._version = decode_version(ver)
+ self._version = ver
def _write_metadata(self):
# Write the 1K metadata block at the beginning of the storage.
@@ -415,7 +414,7 @@
self._file.write(self._format_version)
# If self._version is not yet set, write all zeros.
if self._version is not None:
- self._file.write(encode_version(self._version))
+ self._file.write(self._version)
else:
self._file.write("\0" * 4)
# Fill the rest with null bytes