[ZODB-Dev] strange commit error
Miles
miles at jamkit.com
Thu Dec 4 08:46:17 EST 2008
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?
>
>> 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.
Thanks,
Miles
More information about the ZODB-Dev
mailing list