[ZODB-Dev] Blobs, Copies, and Exports (Zope 3)

Jeff Shell jeff at bottlerocket.net
Fri Oct 24 13:45:17 EDT 2008


On Oct 24, 2008, at 8:36 AM, Christian Theune wrote:
> Again: blobs export as expected.
>
> However, Jeff pickles/unpickles the subtree to get rid of the
> '__parent__' attribute. This and blobs' inability to get copied around
> in this specific manner make him end up with empty blobs.


This is the real issue. What can be done to address it? This sounds  
like something that should be handled at/near the ZODB/Pickle/Copy  
(deep copy?) level.

While doing some google searches on this issue, I saw others having  
same or similar concerns when using Blobs with other tools that did  
deep copies of objects, although their bugs seemed related more to the  
issue of having 'None' values in the readers and writers attributes of  
the Blob file (a bug which has been fixed).

The initial traceback in this bug report is tied to that issue:

https://bugs.launchpad.net/zope3/+bug/240381

But then things swing around to actual content copying. Christophe  
Combelles last comment (from June) shows manually patching  
'zope.location....locationCopy' to address his particular situation.  
'loc' is the original 'located' object being copied.

     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

That's obviously not a general solution, or the most efficient, but  
I'm guessing it's pretty close to what needs to happen...

I just verified that with our CMS (built on Zope 3) and custom  
'BlobFile' content type object, copying the BlobFile content type  
object copies all of the other persistent data of the object, but the  
Blob contents are indeed empty. This is using a copy/paste system  
built on top of zope.copypastemove.

Thanks,
Jeff Shell
jeff at bottlerocket.net



More information about the ZODB-Dev mailing list