Hi David,

No plans yet. I often accomplish these sorts of things using a
baseclass/subclass of FSMAction. Hopefully the following (UNTESTED)
code helps you along.

===

OBSERVERS = 'observers'

class ObserverFSMAction(FSMAction):
  # this is an abstract base class
  def execute(self, context, obj):
    self._execute(self, context, obj)
    for observer in context.get(OBSERVERS, []):
      observer.notify()
  def _execute(self, context, obj):
    raise NotImplementedError()

class MyFSMAction(ObserverFSMAction):
  # use this class in your fsm.yaml
  def _execute(self, context, obj):
    # actually do stuff and return event
    # eg. add an observer
    # NOTE: this is truly untested, but it should work
    context[OBSERVERS] = context.get(OBSERVERS, []) +
[ObserverImpl(...)]

class Observer(object):
  def __init__(self, a_string_to_construct_an_instance_of_observer):
    self._observerImpl = # make impl from supplied string
  def notify():
    self._observerImpl.notify()

class ObserverImpl(Observer):
    def __init__(self, *args, **kwargs):
      # make a useful observer
    def __str__(self): # or maybe __unicode__ is required, can't
recall what webapp does with url params
      # return a string that can be used to reconstruct self - maybe
just call __repr__?
    def notify():
      # do stuff

and in fsm.yaml

context_types:
  observers: module.name.of.Observer

This would only act at the FSMAction level, not the state transition
level. Subclasses of FSMContext/FSMState which override .dispatch()
can also be very powerful - but these required bigger changes to the
framework. The previous example can be accomplished out-of-box

On Jun 9, 2:05 pm, David Mora <[email protected]> wrote:
> BTW - any intentions on plugging an observer pattern/plugin around it :) ?
> It would be awesome to have a list of observers watching for change on
> states (subject)
>
> On 9 June 2011 12:22, David Mora <[email protected]> wrote:
>
>
>
>
>
>
>
>
>
> > i'm also using it right now for some moderation flows i need to finish so i
> > will test it too
>
> > On 9 June 2011 10:14, Jason Collins <[email protected]> wrote:
>
> >> @Mike_W, I've updated the docs to describe this new feature.
>
> >>  http://code.google.com/p/fantasm/wiki/AdvancedConcepts#Fan-In
>
> >> j
>
> >> On Jun 8, 9:44 pm, Robert Kluin <[email protected]> wrote:
> >> > Hey Shawn,
> >> >   Awesome,  I'll try to review it tomorrow!
>
> >> >   Hopefully Mike is still following this thread and will help us test
> >> > it out.  :)
>
> >> > Robert
>
> >> > On Wed, Jun 8, 2011 at 12:03, Shawn <[email protected]> wrote:
> >> > > Hi Robert,
> >> > > Done.http://code.google.com/p/fantasm/source/detail?r=147.
> >> > > Please give it a quick review if you are able.
> >> > > Thanks again.
> >> > > --
> >> > > Shawn
>
> >> > > --
> >> > > You received this message because you are subscribed to the Google
> >> Groups
> >> > > "Google App Engine" group.
> >> > > To view this discussion on the web visit
> >> > >https://groups.google.com/d/msg/google-appengine/-/Y2FNTEJHRWdqczhK.
> >> > > To post to this group, send email to
> >> [email protected].
> >> > > To unsubscribe from this group, send email to
> >> > > [email protected].
> >> > > For more options, visit this group at
> >> > >http://groups.google.com/group/google-appengine?hl=en.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Google App Engine" group.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected].
> >> For more options, visit this group at
> >>http://groups.google.com/group/google-appengine?hl=en.
>
> > --
> >http://about.me/david.mora
>
> --http://about.me/david.mora

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to