Comment 4 for bug 240381

Revision history for this message
Christophe Combelles (ccomb) wrote :

Where is the blobfile supposed to be copied?
Should it be copied during the pickling/unpickling of the blob object, by sort some of hook ?

Actually, the pickling/unpickling is initiated in zope.location.pickling.locationCopy,
and I've tried an small hack that writes the new blobfile at the end of this function.

By replacing:

    return unpickler.load()

with:

    copied = unpickler.load()
    if hasattr(copied, '_data') and type(copied._data) is Blob:
        copied._data._create_uncommitted_file()
        targetfile = open(copied._data._current_filename(), 'w')
        sourcefile = loc.openDetached()
        chunk = sourcefile.read(1000000)
        while chunk:
            targetfile.write(chunk)
            chunk = sourcefile.read(1000000)
        targetfile.close()
    return copied

It also need the fix mentionned in my previous comment (blob.py).