All pastes #206523 Raw Edit

wosc

public text v1 · immutable
#206523 ·published 2006-10-17 13:12 UTC
rendered paste body
"""
You can subscribe to events using the @grok.subscribe decorator:

  >>> grok.grok(__name__)
  >>> manfred = Mammoth('Manfred')
  >>> grok.notify(grok.ObjectCreatedEvent(manfred))
  >>> mammoths
  ['Manfred']

"""
import grok

class Mammoth(object):
    def __init__(self, name):
        self.name = name

mammoths = []

@grok.subscribe(Mammoth, grok.IObjectCreatedEvent)
def mammothAdded(mammoth, event):
    mammoths.append(mammoth.name)