[Zodb-checkins] CVS: StandaloneZODB/ZODB - BaseStorage.py:1.16.8.3
Jeremy Hylton
jeremy@zope.com
Mon, 7 Jan 2002 18:02:12 -0500
Update of /cvs-repository/StandaloneZODB/ZODB
In directory cvs.zope.org:/tmp/cvs-serv7219/ZODB
Modified Files:
Tag: Standby-branch
BaseStorage.py
Log Message:
Add isReadOnly() method and implementation thereof.
Reformat a bunch of methods so the body is on a separate line from the
def.
=== StandaloneZODB/ZODB/BaseStorage.py 1.16.8.2 => 1.16.8.3 ===
_serial=z64 # Transaction serial number
_tstatus=' ' # Transaction status, used for copying data
+ _is_read_only = 0
def __init__(self, name, base=None):
@@ -57,15 +58,24 @@
raise POSException.StorageTransactionError(self, transaction)
return []
- def close(self): pass
+ def close(self):
+ pass
- def getName(self): return self.__name__
- def getSize(self): return len(self)*300 # WAG!
- def history(self, oid, version, length=1): pass
+ def getName(self):
+ return self.__name__
+
+ def getSize(self):
+ return len(self)*300 # WAG!
+
+ def history(self, oid, version, length=1):
+ pass
- def modifiedInVersion(self, oid): return ''
+ def modifiedInVersion(self, oid):
+ return ''
def new_oid(self, last=None):
+ if self._is_read_only:
+ raise POSException.ReadOnlyError()
if last is None:
self._lock_acquire()
try:
@@ -81,10 +91,17 @@
if d < 255: return last[:-1]+chr(d+1)+'\0'*(8-len(last))
else: return self.new_oid(last[:-1])
- def registerDB(self, db, limit): pass # we don't care
+ def registerDB(self, db, limit):
+ pass # we don't care
- def supportsUndo(self): return 0
- def supportsVersions(self): return 0
+ def isReadOnly(self):
+ return self._is_read_only
+
+ def supportsUndo(self):
+ return 0
+
+ def supportsVersions(self):
+ return 0
def tpc_abort(self, transaction):
self._lock_acquire()
@@ -173,15 +190,22 @@
pass
def undo(self, transaction_id):
+ if self._is_read_only:
+ raise POSException.ReadOnlyError()
raise POSException.UndoError, 'non-undoable transaction'
- def undoLog(self, first, last, filter=None): return ()
+ def undoLog(self, first, last, filter=None):
+ return ()
- def versionEmpty(self, version): return 1
+ def versionEmpty(self, version):
+ return 1
- def versions(self, max=None): return ()
+ def versions(self, max=None):
+ return ()
- def pack(self, t, referencesf): pass
+ def pack(self, t, referencesf):
+ if self._is_read_only:
+ raise POSException.ReadOnlyError()
def getSerial(self, oid):
self._lock_acquire()