mirror of
https://github.com/django/daphne.git
synced 2025-07-10 16:02:18 +03:00
Provide keyword args as self.kwargs in CBC (ref. #224)
This commit is contained in:
parent
15aa962cd7
commit
5eb3bf848c
|
@ -26,6 +26,7 @@ class BaseConsumer(object):
|
||||||
the uninstantiated class, so calling it creates it)
|
the uninstantiated class, so calling it creates it)
|
||||||
"""
|
"""
|
||||||
self.message = message
|
self.message = message
|
||||||
|
self.kwargs = kwargs
|
||||||
self.dispatch(message, **kwargs)
|
self.dispatch(message, **kwargs)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -32,7 +32,8 @@ Here's a routing example::
|
||||||
|
|
||||||
Class-based consumers are instantiated once for each message they consume,
|
Class-based consumers are instantiated once for each message they consume,
|
||||||
so it's safe to store things on ``self`` (in fact, ``self.message`` is the
|
so it's safe to store things on ``self`` (in fact, ``self.message`` is the
|
||||||
current message by default).
|
current message by default, and ``self.kwargs`` are the keyword arguments
|
||||||
|
passed in from the routing).
|
||||||
|
|
||||||
Base
|
Base
|
||||||
----
|
----
|
||||||
|
@ -62,6 +63,13 @@ If you want to perfom more complicated routing, you'll need to override the
|
||||||
remember, though, your channel names cannot change during runtime and must
|
remember, though, your channel names cannot change during runtime and must
|
||||||
always be the same for as long as your process runs.
|
always be the same for as long as your process runs.
|
||||||
|
|
||||||
|
``BaseConsumer`` and all other generic consumers than inherit from it provide
|
||||||
|
two instance variables on the class:
|
||||||
|
|
||||||
|
* ``self.message``, the :ref:`Message object <ref-message>` representing the
|
||||||
|
message the consumer was called for.
|
||||||
|
* ``self.kwargs``, keyword arguments from the :doc:`routing`
|
||||||
|
|
||||||
|
|
||||||
WebSockets
|
WebSockets
|
||||||
----------
|
----------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user