def get_resource_events(request, after_commit=False):
 by_resource = request.bound_data.get('resource_events', {})
 events = []
 for (action, payload, impacted, request) in by_resource.values():
  if after_commit:
   if (action == ACTIONS.READ):
    event_cls = AfterResourceRead
   else:
    event_cls = AfterResourceChanged
  elif (action == ACTIONS.READ):
   event_cls = ResourceRead
  else:
   event_cls = ResourceChanged
  event = event_cls(payload, impacted, request)
  events.append(event)
 return events

def get_resource_events ( request , after_commit = False ) : by_resource = request . bound_data . get ( 'resource_events' , { } ) events = [ ] for ( action , payload , impacted , request ) in by_resource . values ( ) : if after_commit : if ( action == ACTIONS . READ ) : event_cls = AfterResourceRead else : event_cls = AfterResourceChanged elif ( action == ACTIONS . READ ) : event_cls = ResourceRead else : event_cls = ResourceChanged event = event_cls ( payload , impacted , request ) events . append ( event ) return events
request helper to return the list of events triggered on resources .