<ke***********@yahoo.com> wrote in message
news:f0*************************@posting.google.co m...
Hi
Does python support MVC architecture? Java has register & notify
obsever methods in javax.util . Does python has these functions. If
not then how to register the views with the models & how to notify the
views that the model has been updated??
I don't know of a notifier class in the standard library,
but it's not all that difficult to write one. This is the
one I am currently using:
-----------------------------------------------------
# module Notify
class Notify(object):
def __init__(self):
self.listenerList = []
def sendMessage(self, event):
for callback in self.listenerList:
callback(event)
return
def addListener(self, callback):
self.listenerList.append(callback)
def removeListener(self, callback):
self.listenerList.remove(callback)
-----------------------------------------------------
callback has to be a callable of some kind,
a bound method is perfectly acceptable and
that's what I use. Works great.
John Roth