does python support mvc architecture
John Roth
newsgroups at jhrothjr.com
Thu Feb 12 09:40:21 EST 2004
<ketulp_baroda at yahoo.com> wrote in message
news:f046efac.0402120627.948b7ed at posting.google.com...
> 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
More information about the Python-list
mailing list