dag / braindump

Ideas and Experiments
1 stars 1 forks source link

Generic toolkit for extensible applications #7

Open dag opened 13 years ago

dag commented 13 years ago

Probably a complete ripoff of existing options such as the ZCA. I should blame moraes for bugging me about it. :)

# an instance of a jinja environment has been created and registered
@created(jinja2.Environment)
def configure_line_statements(env):  # pass the instance as the first argument
    env.line_statement_prefix = '#'

# a request has started
# find all utilities in the registry matching the annotated types in the function signature
# call the function once for each combination of the found utilities
@started(RequestEvent)
def log_request(log: logbook.Logger, request: werkzeug.BaseRequest):
    log.info('{request.method} {request.path}', request=request)