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:


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:
         targetfile = open(copied._data._current_filename(), 'w')
         sourcefile = loc.openDetached()
         chunk = sourcefile.read(1000000)
         while chunk:
             chunk = sourcefile.read(1000000)
     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.

Jeff Shell

For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to