By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,818 Members | 1,262 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,818 IT Pros & Developers. It's quick & easy.

does python support mvc architecture

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
<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

P: n/a
"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

P: n/a
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

P: n/a
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.