thorn.app

Thorn Application.

class thorn.app.Thorn(dispatcher=None, set_as_current=True)[source]

Thorn application.

Dispatcher[source]
Event[source]
ModelEvent[source]
Request[source]
Settings[source]
Subscriber
Subscribers
autodetect_env(apply=<operator.methodcaller object>)[source]
config
disable_buffer(owner=None)[source]

Disable buffering.

Raises:
  • BufferNotEmpty – if there are still items in the
  • buffer when disabling.
dispatcher[source]
dispatchers = {u'default': u'thorn.dispatch.base:Dispatcher', u'celery': u'thorn.dispatch.celery:Dispatcher', u'disabled': u'thorn.dispatch.disabled:Dispatcher'}
enable_buffer(owner=None)[source]

Start buffering up events instead of dispatching them directly.

Note

User will be responsible for flushing the buffer via flush_buffer(), say periodically or at the end of a web request.

env[source]
environments = set([u'thorn.environment.django:DjangoEnv'])
event_cls = u'thorn.events:Event'
flush_buffer(owner=None)[source]

Flush events accumulated while buffering active.

Note

This will force send any buffered events, but the mechanics of how this happens is up to the dispatching backend:

  • default

    Sends buffered events one by one.

  • celery

    Sends a single message containing all buffered events, a worker will then pick that up and execute the web requests.

hmac_sign[source]
model_event_cls = u'thorn.events:ModelEvent'
model_reverser[source]
on_commit
request_cls = u'thorn.request:Request'
reverse
set_current()[source]
set_default()[source]
settings[source]
settings_cls = u'thorn.conf:Settings'
signals
subclass_with_self(Class, name=None, attribute=u'app', reverse=None, keep_reduce=False, **kw)[source]

Subclass an app-compatible class.

App-compatible means the class has an ‘app’ attribute providing the default app, e.g.: class Foo(object): app = None.

Parameters:

Class (Any) – The class to subclass.

Keyword Arguments:
 
  • name (str) – Custom name for the target subclass.
  • attribute (str) – Name of the attribute holding the app. Default is "app".
  • reverse (str) – Reverse path to this object used for pickling purposes. E.g. for app.AsyncResult use "AsyncResult".
  • keep_reduce (bool) – If enabled a custom __reduce__ implementation will not be provided.
webhook_model[source]