[ZODB-Dev] strange commit error
Jim Fulton
jim at zope.com
Thu Dec 4 12:11:47 EST 2008
On Dec 4, 2008, at 8:46 AM, Miles wrote:
> Hi,
>
> Thanks for your help
>
> <snip>
>
>>>
>>> (from ZODB.serialize.py - line 350)
>>>
>>> if obj._p_jar._implicitlyAdding(oid):
>>> raise InvalidObjectReference(
>>> "A new object is reachable from multiple
>>> databases. "
>>> "Won't try to guess which one was correct!"
>>> )
>>>
>>> Can anyone shed any light on what this error means?!
>>
>> It means a new object is referenced from objects in multiple
>> databases
>> and it doesn't know what database to assign it to.
>
> After some digging into the objects, I think I understand this. It's
> come up as follows:
>
> - I load object A from the old database
> - Object A has an attribute B, which is an object also in the old
> database
> - I create a fresh copy of A, but leave the attribute B remained a
> reference to B in the old database
> - When I went to commit A, I got an error because A.B points to the
> old database still
>
> Is this right?
No. The error is about a *new* object that is refered to from both
databases.
>
>
>>
>>> Given a persistent
>>> object, what is the correct way to get a completely fresh copy
>>> that is
>>> not tied to any database at all, so I can transfer these old objects
>>> to
>>> the current database.
>>
>> I would use the database export/import API to export it from one
>> database and import it to another. (There are issues with doing this
>> in Zope 3, but I assume you're using Zope 2.
>
> Sorry if I'm being thick - I thought the code below did indeed use the
> export/import API:
>
> f=tempfile.TemporaryFile()
> old_ob._p_jar.exportFile(old_ob._p_oid,f)
> f.seek(0)
> container = app.new_folder
> ob=container._p_jar.importFile(f)
>
> Is this what you meant? If so, I'll do some more digging.
Oops, I didn't notice that you were already doing this. This is odd.
I'm at a loss.
- Does your application involve multiple databases, aside from the
databases
you are copying data between?
- How complex is the object in question?
Jim
--
Jim Fulton
Zope Corporation
More information about the ZODB-Dev
mailing list