Permalink
Browse files

Allow kwargs to events after all

  • Loading branch information...
1 parent 0b82ed8 commit 75b02d604a5f2be5a34aa149ccfee2aafe7ae12a @brendonh committed Oct 8, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 warp/common/events.py
@@ -48,19 +48,20 @@ def commit(self):
class EventModel(Storm):
- def emit(self, event):
+ def emit(self, event, **kwargs):
store = get_obj_info(self)["store"]
if store is None:
raise Exception("Tried to emit event for store-less object")
- store.events.append(PendingEvent(self, event))
+ store.events.append(PendingEvent(self, event, kwargs))
class PendingEvent(object):
- def __init__(self, obj, event):
+ def __init__(self, obj, event, kwargs=None):
self.obj = obj
self.event = event
+ self.kwargs = kwargs
def run(self):
modelName = self.obj.__class__.__name__
@@ -69,7 +70,7 @@ def run(self):
for handler in eventHandlers:
try:
- handler(self.obj)
+ handler(self.obj, **self.kwargs)
except Exception:
print ">>> Error in event handler"
traceback.print_exc()

0 comments on commit 75b02d6

Please sign in to comment.