Copying Persistent instances, was Re: SystemSpecifyer, was Re: [ZODB-Dev] How to predict George Bailey?
Christian Reis
kiko@async.com.br
Thu, 7 Nov 2002 12:46:49 -0200
On Thu, Nov 07, 2002 at 12:01:42PM +0000, Toby Dickenson wrote:
> If the view is only showing a part of the document, then the view object
> definitely stores its own copy of the state which specifies the location
> within the document.
I've been toying with the idea of using an actual copy of the instance
when attaching it to a View. I think I haven't mentioned it before, but I
work on a UI framework called Kiwi (http://www.async.com.br/projects/kiwi)
that offers something called a Visual Proxy. It is a special type of
view that attaches itself to an instance, and all changes done to the
view are transparently reflected in the instance (and vice-versa).
Now, the Proxy currently has instant update semantics, which isn't very
good for applications with multiple views and persistence (and anyway,
many apps don't want instant-update for *all* their views). So I've
began writing what I call a ghost Proxy (or whatever). This proxy would
hold a *copy* of the instance (not the real instance), and state would
be migrated to it on a specific commit() call.
I'm thinking about a way to copy the instance, though. The best way so
far seems to be manually copying the state and methods into a shell
object using introspection; copy.deepcopy() and friends don't work out
of the box (I don't blame them) and creating a new instance doesn't seem
to be a good idea. So I'm finally back to that old "implement
__copy__()" suggestion Toby gave me what back in May:
http://lists.zope.org/pipermail/zodb-dev/2002-May/002650.html
Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL