[Zope3-checkins] CVS: Zope3/src/zodb/storage - base.py:1.1.2.4 file.py:1.1.2.6 fsdump.py:1.1.2.2 fsindex.py:1.1.2.2 fsrecover.py:1.1.2.2 mapping.py:1.1.2.4
Tim Peters
tim.one@comcast.net
Tue, 24 Dec 2002 21:21:36 -0500
Update of /cvs-repository/Zope3/src/zodb/storage
In directory cvs.zope.org:/tmp/cvs-serv19240/src/zodb/storage
Modified Files:
Tag: NameGeddon-branch
base.py file.py fsdump.py fsindex.py fsrecover.py mapping.py
Log Message:
Whitespace normalization, via Python's Tools/scripts/reindent.py. The
files are fixed-points of that script now. Fixed a few cases where
code relied on significant trailing whitespace (ouch).
=== Zope3/src/zodb/storage/base.py 1.1.2.3 => 1.1.2.4 ===
--- Zope3/src/zodb/storage/base.py:1.1.2.3 Tue Dec 24 11:20:02 2002
+++ Zope3/src/zodb/storage/base.py Tue Dec 24 21:20:02 2002
@@ -72,10 +72,10 @@
def getName(self):
return self._name
-
+
def history(self, oid, version, length=1):
pass
-
+
def modifiedInVersion(self, oid):
return ''
@@ -103,10 +103,10 @@
def isReadOnly(self):
return self._is_read_only
-
+
def supportsVersions(self):
return False
-
+
def tpc_abort(self, transaction):
self._lock_acquire()
try:
@@ -257,7 +257,7 @@
def getExtensionMethods(self):
"""getExtensionMethods
-
+
This returns a dictionary whose keys are names of extra methods
provided by this storage. Storage proxies (such as ZEO) should
call this method to determine the extra methods that they need
@@ -265,7 +265,7 @@
Dictionary values should be None; this will be a handy place
for extra marshalling information, should we need it
"""
- return {}
+ return {}
def copyTransactionsFrom(self, other, verbose=0):
"""Copy transactions from another storage.
=== Zope3/src/zodb/storage/file.py 1.1.2.5 => 1.1.2.6 ===
--- Zope3/src/zodb/storage/file.py:1.1.2.5 Mon Dec 23 18:48:42 2002
+++ Zope3/src/zodb/storage/file.py Tue Dec 24 21:20:02 2002
@@ -238,7 +238,7 @@
def _read_txn_header(self, pos):
pass
-
+
def _loadBack_impl(self, oid, back):
# shared implementation used by various _loadBack methods
while 1:
@@ -1117,7 +1117,7 @@
self._file.seek(tpos)
h = self._file.read(TRANS_HDR_LEN)
if h[16] != ' ':
- raise UndoError(None, 'non-undoable transaction')
+ raise UndoError(None, 'non-undoable transaction')
tl = u64(h[8:16])
ul, dl, el = struct.unpack(">HHH", h[17:TRANS_HDR_LEN])
tend = tpos + tl
@@ -1337,8 +1337,8 @@
self._lock_acquire()
self._packt = z64
self._lock_release()
-
-
+
+
def iterator(self, start=None, stop=None):
return FileIterator(self._file_name, start, stop)
@@ -1429,7 +1429,7 @@
def pack(self):
packing = True
-
+
##################################################################
# Step 1, get index as of pack time that has only referenced objects.
index = fsIndex()
@@ -1672,7 +1672,7 @@
self._commit_lock_acquire()
self._lock_acquire()
self.locked = True
-
+
# OK, we've copied everything. Now we need to wrap things up.
ofile.flush()
ofile.close()
@@ -2195,7 +2195,7 @@
class RecordIterator(Iterator, FileStorageFormatter, base.TransactionRecord):
"""Iterate over the transactions in a FileStorage file."""
-
+
def __init__(self, tid, status, user, desc, ext, pos, tend, file, tpos):
self.tid = tid
self.status = status
@@ -2323,7 +2323,7 @@
def fromString(cls, s):
return cls(*struct.unpack(DATA_HDR, s))
-
+
fromString = classmethod(fromString)
def parseVersion(self, buf):
=== Zope3/src/zodb/storage/fsdump.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zodb/storage/fsdump.py:1.1.2.1 Mon Dec 23 14:30:49 2002
+++ Zope3/src/zodb/storage/fsdump.py Tue Dec 24 21:20:02 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
import struct
=== Zope3/src/zodb/storage/fsindex.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zodb/storage/fsindex.py:1.1.2.1 Mon Dec 23 14:30:49 2002
+++ Zope3/src/zodb/storage/fsindex.py Tue Dec 24 21:20:02 2002
@@ -2,33 +2,33 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""Implement an OID to File-position (long integer) mapping
"""
-#
+#
# To save space, we do two things:
-#
+#
# 1. We split the keys (OIDS) into 6-byte prefixes and 2-byte suffixes.
# We use the prefixes as keys in a mapping from prefix to mappings
# of suffix to data:
-#
+#
# data is {prefix -> {suffix -> data}}
-#
+#
# 2. We limit the data size to 48 bits. This should allow databases
# as large as 256 terabytes.
-#
+#
# Mostof the space is consumed by items in the mappings from 2-byte
# suffix to 6-byte data. This should reduce the overall memory usage to
# 8-16 bytes per OID.
-#
+#
# We use p64 to convert integers to 8-byte strings and lop off the two
# high-order bytes when saving. On loading data, we add the leading
# bytes back before using u64 to convert the data back to (long)
@@ -51,7 +51,7 @@
if h:
return (long(h) << 32) + l
else:
- return l
+ return l
class fsIndex:
=== Zope3/src/zodb/storage/fsrecover.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zodb/storage/fsrecover.py:1.1.2.1 Mon Dec 23 14:30:49 2002
+++ Zope3/src/zodb/storage/fsrecover.py Tue Dec 24 21:20:02 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""Simple script for repairing damaged FileStorage files.
@@ -47,14 +47,14 @@
Pack data to t seconds in the past. Note that is the "-p"
option is used, then t should be 0.
-
+
Important note: The ZODB package must be imporable. You may need
to adjust the Python path accordingly.
"""
# Algorithm:
-#
+#
# position to start of input
# while 1:
# if end of file: break
@@ -79,7 +79,7 @@
elif os.path.exists('FileStorage.py'): sys.path.append('..')
import ZODB
-
+
import getopt, ZODB.FileStorage, struct, time
from struct import unpack
from zodb.utils import t32, p64, u64
@@ -183,7 +183,7 @@
sys.stdout.flush()
def progress(p):
- for i in range(p): iprogress(i)
+ for i in range(p): iprogress(i)
def recover(argv=sys.argv):
@@ -197,7 +197,7 @@
elif opt == '-f': force=1
elif opt == '-P': pack=time.time()-float(v)
-
+
force = filter(lambda opt: opt[0]=='-f', opts)
partial = filter(lambda opt: opt[0]=='-p', opts)
verbose = filter(lambda opt: opt[0]=='-v', opts)
@@ -206,7 +206,7 @@
except:
die()
print __doc__ % argv[0]
-
+
if os.path.exists(outp) and not force:
die("%s exists" % outp)
@@ -265,7 +265,7 @@
ok=1
if verbose:
- print 'begin',
+ print 'begin',
if verbose > 1: print
sys.stdout.flush()
@@ -315,13 +315,12 @@
print "\n%s bytes removed during recovery" % bad
if undone:
print "%s bytes of undone transaction data were skipped" % undone
-
+
if pack is not None:
print "Packing ..."
ofs.pack(pack)
ofs.close()
-
-if __name__=='__main__': recover()
+if __name__=='__main__': recover()
=== Zope3/src/zodb/storage/mapping.py 1.1.2.3 => 1.1.2.4 ===
--- Zope3/src/zodb/storage/mapping.py:1.1.2.3 Mon Dec 23 17:43:14 2002
+++ Zope3/src/zodb/storage/mapping.py Tue Dec 24 21:20:02 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""Very Simple Mapping ZODB storage
@@ -53,7 +53,7 @@
A record is a tuple:
- oid, serial, pre, vdata, p,
+ oid, serial, pre, vdata, p,
where:
@@ -137,7 +137,7 @@
oserial=old[:8]
if serial != oserial:
raise interfaces.ConflictError(serials=(oserial, serial))
-
+
serial=self._serial
self._tindex.append((oid,serial+data))
finally: self._lock_release()
@@ -154,7 +154,7 @@
def pack(self, t):
self._lock_acquire()
- try:
+ try:
# Build an index of *only* those objects reachable
# from the root.
index=self._index
@@ -165,7 +165,7 @@
while rootl:
oid=pop()
if referenced(oid): continue
-
+
# Scan non-version pickle for references
r=index[oid]
pindex[oid]=r
@@ -175,7 +175,7 @@
# Now delete any unreferenced entries:
for oid in index.keys():
if not referenced(oid): del index[oid]
-
+
finally: self._lock_release()
def _splat(self):
@@ -189,5 +189,5 @@
r=index[oid]
o.append(' %s: %s, %s' %
(utils.u64(oid),TimeStamp(r[:8]),`r[8:]`))
-
+
return "\n".join(o)