Commit 4b6ab743 authored by Jim Fulton's avatar Jim Fulton

Removed the unnecessary and unused version argument from storeBlob.

Added a temporaryDirectory method for getting a directory to use for
creating temporary files.
parent 6c2e5364
......@@ -61,6 +61,11 @@ class BlobStorage(SpecificationDecoratorBase):
supportsUndo = supportsUndo()
self.__supportsUndo = supportsUndo
@non_overridable
def temporaryDirectory(self):
return self.fshelper.base_dir
@non_overridable
def __repr__(self):
normal_storage = getProxiedObject(self)
......@@ -114,13 +119,12 @@ class BlobStorage(SpecificationDecoratorBase):
os.unlink(clean)
@non_overridable
def loadBlob(self, oid, serial, version):
def loadBlob(self, oid, serial):
"""Return the filename where the blob file can be found.
"""
filename = self.fshelper.getBlobFilename(oid, serial)
if not os.path.exists(filename):
raise POSKeyError, "Not an existing blob."
return None
return filename
@non_overridable
......
......@@ -60,11 +60,16 @@ class IBlobStorage(Interface):
def storeBlob(oid, oldserial, data, blob, version, transaction):
"""Stores data that has a BLOB attached."""
def loadBlob(oid, serial, version):
"""Return the filename of the Blob data responding to this OID and
serial.
def loadBlob(oid, serial):
"""Return the filename of the Blob data for this OID and serial.
Returns a filename or None if no Blob data is connected with this OID.
Raises POSKeyError if the blobfile cannot be found.
"""
def temporaryDirectory():
"""Return a directory that should be used for uncommitted blob data.
If Blobs use this, then commits can be performed with a simple rename.
"""
......@@ -853,8 +853,7 @@ class Connection(ExportImport, object):
providedBy = getattr(obj, '__providedBy__', None)
if providedBy is not None and IBlob in providedBy:
obj._p_blob_uncommitted = None
obj._p_blob_data = self._storage.loadBlob(
obj._p_oid, serial, self._version)
obj._p_blob_data = self._storage.loadBlob(obj._p_oid, serial)
def _load_before_or_conflict(self, obj):
"""Load non-current state for obj or raise ReadConflictError."""
......@@ -1108,7 +1107,7 @@ class Connection(ExportImport, object):
for oid in oids:
data, serial = src.load(oid, src)
try:
blobfilename = src.loadBlob(oid, serial, self._version)
blobfilename = src.loadBlob(oid, serial)
except POSKeyError:
s = self._storage.store(oid, serial, data,
self._version, transaction)
......@@ -1250,7 +1249,7 @@ class TmpStore:
targetname = self._getCleanFilename(oid, serial)
os.rename(blobfilename, targetname)
def loadBlob(self, oid, serial, version):
def loadBlob(self, oid, serial):
"""Return the filename where the blob file can be found.
"""
filename = self._getCleanFilename(oid, serial)
......
......@@ -39,6 +39,7 @@ class ExportImport:
done_oids = {}
done=done_oids.has_key
load=self._storage.load
supports_blobs = IBlobStorage.providedBy(self._storage)
while oids:
oid = oids.pop(0)
if oid in done_oids:
......@@ -52,13 +53,14 @@ class ExportImport:
else:
referencesf(p, oids)
f.writelines([oid, p64(len(p)), p])
# Blob support
if not IBlobStorage.providedBy(self._storage):
continue
try:
blobfilename = self._storage.loadBlob(oid,
serial, self._version)
except POSKeyError: # Looks like this is not a blob
if supports_blobs:
if 'Blob' not in p:
continue # filter out most non-blobs
blobfilename = self._storage.loadBlob(oid, serial)
if blobfilename is None:
# This could be a non-blob or a blob with unsaved data.
continue
f.write(blob_begin_marker)
......
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