Rewrite contextvar usage. Implemented ContextInstanceMixin and DataMixin

This commit is contained in:
Alex Root Junior 2018-10-20 15:55:57 +03:00
parent 8ef279bba1
commit 39c333251f
12 changed files with 82 additions and 120 deletions

View file

@ -56,7 +56,7 @@ class ThrottlingMiddleware(BaseMiddleware):
handler = current_handler.get()
# Get dispatcher from context
dispatcher = Dispatcher.current()
dispatcher = Dispatcher.get_current()
# If handler was configured, get rate limit and key from handler
if handler:
limit = getattr(handler, 'throttling_rate_limit', self.rate_limit)
@ -83,7 +83,7 @@ class ThrottlingMiddleware(BaseMiddleware):
:param throttled:
"""
handler = current_handler.get()
dispatcher = Dispatcher.current()
dispatcher = Dispatcher.get_current()
if handler:
key = getattr(handler, 'throttling_key', f"{self.prefix}_{handler.__name__}")
else: