[ZODB-Dev] Reachability and GUI apps

Rad Widmer rwidmer at eclypse.org
Wed Jun 30 15:18:47 EDT 2004


This is my first post to this list. I've never used ZODB before, but I'm thinking of switching to it
for an app I'm currently developing using wxPython and MySQL. The code is layered, so there are
domain object classes, GUI-related classes, and persistence layer classes. For the most part, the
domain objects (which would be the persistent classes in a ZODB app) do not depend on the other
layers. There is one exception that I've seen so far. I'm using a simple implementation of the
Observer pattern, which stores a list of references to observer objects in the Subject (observable)
object. For example, I have a Part class, which is a persistent obj, and it also inherits from
Subject, so that GUI objs can observe it. When a GUI object wishes to observe the Part object, it
calls an attach method on the Part object, which saves a reference to the GUI obj in the Part obj.
The problem is, now I have GUI objects which are reachable from my persistent objects, and so the
GUI objs would be persisted along with the domain objects.

Is my understanding of reachability correct? Has anyone had a similar situation, and how have you
handled it? One approach I can think of would be to switch to a mediator-type of Publish/Subscribe
pattern (such as the pubsub module in wxPython), where a single pubsub object is used to hold all
references to observers, and to which objects post when an update occurs. With this approach, I
wouldn't need to have a reference to the pubsub object in my domain classes (it could be some kind
of global reference).

Thanks in advance,

Rad Widmer





More information about the ZODB-Dev mailing list