Global hooks/exception handlers for event scripts

At the moment most of our event scripts look like this:

from app import dc
e = dc.Event(event)
    # do stuff

dc.Event is a wrapper around the event object that provides various shortcut methods.
e.error() is a nice error handler that logs to the database and hides the stack trace from the user.

Is there any way to hook this in globally so that it will be used for all event handlers without having to add this boilerplate every time?


Not really. You would have to have a boilerplate for something whether it is the try…except or creating a function to pass in.

I hadn’t considered passing a function. That might be a nice improvement.

def handler(event):
    pass, event)

Actually, this has the added bonus of avoiding some of the module scoping issues.