allura.lib.decorators
¶
- class allura.lib.decorators.event_handler(*topics)¶
Decorator to register event handlers
- allura.lib.decorators.getattr_(obj, name, default_thunk)¶
Similar to .setdefault in dictionaries.
- allura.lib.decorators.memoize(wrapper=None, enabled=None, adapter=None, proxy=<class 'FunctionWrapper'>)¶
Cache the method’s result, for the given args
- allura.lib.decorators.memoize_cleanup(obj)¶
Remove any _memoize_dic_* keys that were created by @memoize on methods
- allura.lib.decorators.memorable_forget()¶
Decorator to mark a controller action as needing to “forget” remembered input values on the next page render, if we detect that the form post was processed successfully
- allura.lib.decorators.require_method(*methods)¶
Usage:
@require_method(‘GET’, ‘HEAD’) def foo()
- class allura.lib.decorators.require_post(redir=None)¶
A decorator to require controllers by accessed with a POST only. Use whenever data will be modified by a controller, since that’s what POST is good for. We have CSRF protection middleware on POSTs, too.
- allura.lib.decorators.task(*args, **kw)¶
Decorator that adds a
.post()
function to the decorated callable.Calling
<original_callable>.post(*args, **kw)
queues the callable for execution by a background worker process. All parameters must be BSON-serializable.Example usage:
@task def myfunc(): pass @task(notifications_disabled=True) def myotherfunc(): # No email notifications will be sent for c.project during this task pass