Sniff, was Re: [ZODB-Dev] Copying instances between multiple storages
Toby Dickenson
tdickenson@geminidataloggers.com
Tue, 21 May 2002 13:11:14 +0100
On Tue, 21 May 2002 08:55:01 -0300, Christian Reis <kiko@async.com.br>
wrote:
>On Tue, May 21, 2002 at 11:02:03AM +0100, Toby Dickenson wrote:
>> On Mon, 20 May 2002 18:50:36 -0300, Christian Reis <kiko@async.com.br>
>> wrote:
>>=20
>> >> Fair enough. So what do I have to do? Instance another object and =
copy
>> >> it's data over (ugh)?
>>=20
>> Thats what I would do, if your object is of small finite size.
>
>Really? There is no clone functionality in the ZODB?
Sure, there is the export/import I mentioned later in my post. I still
wouldnt use it if my objects were small.
> I've noticed that
>something has been mentioned called Mount*Storage; I'd suppose it'd do
>something like that, but I haven't seen it yet.
No, it works very differently. It integrates two different object
database at the zope application layer, not at object layer.
>So you suggest I just create a new instance, and iterate through the
>attributes, copying them over.
Thats what I would do if the objects are small.
>>>> import copy
>>>> p =3D get_catalog("Products").dump()[0]
>>>> copy.copy(p)
>Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/usr/local/lib/python2.1/copy.py", line 78, in copy
> raise error, \
>copy.Error: un(shallow)copyable object of type <extension class
>Domain.Product.Product at 83ccba8>
Aha, yes. it doesnt know how to automatically copy extension classes.
You might want to try hacking the copy module so that it uses the
_copy_int function for extension class instances as well as ordinary
functions. I dont see why that shouldnt work (but Ive been known to
be wrong in making statements like that ;-)
>And deepcopy provides me the same error, so I probably have to define
>__*copy__ if it is to work, right?
Yes.=20
>Yes, addressing is another problem, but it doesn't invalidate the
>problems with cloning objects, since I have to support disconnected
>operation (that's the gist of it, actually - I need to copy objects
>between databases).
have you considered a solution at a lower layer; rsync Data.fs ?
Toby Dickenson
tdickenson@geminidataloggers.com