def raise_event(f):
 @wraps(f)
 def decorated(*args, **kwargs):
  r = f(*args, **kwargs)
  method = request.method
  if (method in ('GET', 'POST', 'PATCH', 'DELETE', 'PUT')):
   event_name = ('on_post_' + method)
   resource = (args[0] if args else None)
   getattr(app, event_name)(resource, request, r)
   if resource:
    getattr(app, ((event_name + '_') + resource))(request, r)
  return r
 return decorated

def raise_event ( f ) : @ wraps ( f ) def decorated ( * args , ** kwargs ) : r = f ( * args , ** kwargs ) method = request . method if ( method in ( 'GET' , 'POST' , 'PATCH' , 'DELETE' , 'PUT' ) ) : event_name = ( 'on_post_' + method ) resource = ( args [ 0 ] if args else None ) getattr ( app , event_name ) ( resource , request , r ) if resource : getattr ( app , ( ( event_name + '_' ) + resource ) ) ( request , r ) return r return decorated
raises both general and resource-level events after the decorated function has been executed .