469,360 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

does python support mvc architecture

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??
Jul 18 '05 #1
4 2135
<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
Jul 18 '05 #2
"John Roth" <ne********@jhrothjr.com> writes:
<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.


I can heartily recommend the dispatcher module from Patrick O'Brian.
I'm still using a hacked up version from ActiveState's Python cookbook,
but there's also a newer version on sourceforge.

Thomas
Jul 18 '05 #3
DH
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??


The one that is closest to Java's implementation is here:
http://jamesthornton.com/eckel/TIPython/code/util/
but see also:
http://sra.itc.it/people/cavada/mvc/index.html
http://sourceforge.net/projects/pydispatcher/

And various python frameworks have Observable support built-in, such as
Twisted, anygui, WCK, etc.
Jul 18 '05 #4
DH a écrit :
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??

The one that is closest to Java's implementation is here:
http://jamesthornton.com/eckel/TIPython/code/util/
but see also:
http://sra.itc.it/people/cavada/mvc/index.html
http://sourceforge.net/projects/pydispatcher/

And various python frameworks have Observable support built-in, such as
Twisted, anygui, WCK, etc.


http://www.python.org/cgi-bin/moinmo...tionEventModel

Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Grant Edwards | last post: by
8 posts views Thread by Brendan | last post: by
113 posts views Thread by John Nagle | last post: by
145 posts views Thread by Dave Parker | last post: by
1 post views Thread by M.-A. Lemburg | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.