[Python-Dev] Oberver Pattern

Fredrik Lundh fredrik@pythonware.com
Wed, 15 May 2002 18:42:42 +0200


magnus wrote:

> > > This could be very useful for GUIs, too, for implementing
> > > model-view relationships. The anygui people would be very
> > > interested, I'm sure.
> > 
> > Indeed!
> >
> > have you actually built large-scale UI applications using a
> > one-size-fits-all observer model, or are you just guessing?
> 
> Guessing about what?

the "very useful for implementing model-view relationships"
part, of course.

since you didn't reply to the "large-scale" part, and gave an
example that doesn't really have much to do with model-view
design (unless you're writing a GUI builder, perhaps) I assume
you're still mostly guessing.

if you want something closer to real-life, consider how well a
"standard observer" would deal with the following example:

# load the model
dom = xml.dom.minidom.parse(filename)

# create a view
mywidget = MyDisplayView()
mywidget.show(dom)

# modify the model
for element in dom.getElementsByTagName("sometag"):
    ...

</F>