SystemSpecifyer, was Re: [ZODB-Dev] How to predict George Bailey?

Toby Dickenson tdickenson@geminidataloggers.com
Sun, 3 Nov 2002 20:16:13 +0000


On Sunday 03 November 2002 6:36 pm, Magnus Lycka wrote:

> Let's pretend this is a word processor. Should I drop and
> reload my document every time I press Ctrl-S or Ctrl-Z?

If this word processor is implemented using a M/V/C model, then it would =
be=20
natural for the View to store its own state using its own view-domain=20
properties. It would not be natural for the view to store references to=20
objects in the Document.

This means that the View is constantly acquiring references to document=20
objects, but then dropping them.=20

This does not mean that the document objects have to be reloaded from dis=
k -=20
they can probably be reacquired very quickly from the document object on=20
demand.

(of course M/V/C can be done in other ways - but this approach is the pur=
est,=20
and not uncommon)


Bringing it back to your application..... A Detail Window object could ha=
ve a=20
property which contains the identity of the element which it is displayin=
g.=20
'identity' might be element serial number, or whatever makes sense.

Each time the detail window is rendered, refreshed, or commited (etc) it=20
passes the element identity on to the document root object, and expects t=
o=20
get back a reference to an Element object.

If the document doesnt contain an Element with that identity then it can =
raise=20
a document-level exception. Note *not* a ZODB exception.=20

After an undo the easy approach is to refresh all windows. You will now=20
*never* see a George Bailey object. A window displaying an element which =
no=20
longer exists (because its creation has been undone) will trigger that=20
document-level element-does-not-exists exception.

I think thats how I would do it, with or without ZODB.