does python support mvc architecture

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ketulp_baroda@yahoo.com

    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??
  • John Roth

    #2
    Re: does python support mvc architecture

    <ketulp_baroda@ yahoo.com> wrote in message
    news:f046efac.0 402120627.948b7 ed@posting.goog le.com...[color=blue]
    > 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??[/color]

    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.listenerLi st = []

    def sendMessage(sel f, event):
    for callback in self.listenerLi st:
    callback(event)
    return

    def addListener(sel f, callback):
    self.listenerLi st.append(callb ack)

    def removeListener( self, callback):
    self.listenerLi st.remove(callb ack)
    -----------------------------------------------------

    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


    Comment

    • Thomas Heller

      #3
      Re: does python support mvc architecture

      "John Roth" <newsgroups@jhr othjr.com> writes:
      [color=blue]
      > <ketulp_baroda@ yahoo.com> wrote in message
      > news:f046efac.0 402120627.948b7 ed@posting.goog le.com...[color=green]
      >> 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??[/color]
      >
      > 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.listenerLi st = []
      >
      > def sendMessage(sel f, event):
      > for callback in self.listenerLi st:
      > callback(event)
      > return
      >
      > def addListener(sel f, callback):
      > self.listenerLi st.append(callb ack)
      >
      > def removeListener( self, callback):
      > self.listenerLi st.remove(callb ack)
      > -----------------------------------------------------
      >
      > callback has to be a callable of some kind,
      > a bound method is perfectly acceptable and
      > that's what I use. Works great.[/color]

      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

      Comment

      • DH

        #4
        Re: does python support mvc architecture

        [color=blue]
        >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??[/color]

        The one that is closest to Java's implementation is here:

        but see also:

        Download Python Dispatcher for free. The dispatcher provides loosely-coupled message passing between Python objects (signal senders and receivers). It began as one of the highest-rated recipes on the Python Cookbook website


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

        Comment

        • Yermat

          #5
          Re: does python support mvc architecture

          DH a écrit :[color=blue]
          >[color=green]
          >> 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??[/color]
          >
          >
          > 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.[/color]



          Comment

          Working...