Fixed: Middleware process_response got not executed.
This commit is contained in:
@@ -1,12 +1,26 @@
|
|||||||
"""Middleware to defer slow denormalization at the end of a request."""
|
"""Middleware to defer slow denormalization at the end of a request."""
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
|
|
||||||
from mahjong_ranking import models
|
from mahjong_ranking import models
|
||||||
from . import LOGGER
|
from . import LOGGER
|
||||||
|
from . import LOGGER
|
||||||
|
|
||||||
|
class DenormalizationUpdateMiddleware:
|
||||||
class DenormalizationUpdateMiddleware(object): # Ignore PyLintBear (R0903)
|
|
||||||
"""To recalculate everything in the queues at the end of a POST request."""
|
"""To recalculate everything in the queues at the end of a POST request."""
|
||||||
|
|
||||||
|
def __init__(self, get_response=None):
|
||||||
|
self.get_response = get_response
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
def __call__(self, request):
|
||||||
|
response = None
|
||||||
|
if hasattr(self, 'process_request'):
|
||||||
|
response = self.process_request(request)
|
||||||
|
response = response or self.get_response(request)
|
||||||
|
if hasattr(self, 'process_response'):
|
||||||
|
response = self.process_response(request, response)
|
||||||
|
return response
|
||||||
|
|
||||||
def process_response(self, request, response): # Ignore PyLintBear (R0201)
|
def process_response(self, request, response): # Ignore PyLintBear (R0201)
|
||||||
"""Check and process the recalculation queues on each POST request.
|
"""Check and process the recalculation queues on each POST request.
|
||||||
|
|
||||||
@@ -16,7 +30,6 @@ class DenormalizationUpdateMiddleware(object): # Ignore PyLintBear (R0903)
|
|||||||
"""
|
"""
|
||||||
event_queue = set()
|
event_queue = set()
|
||||||
season_queue = set()
|
season_queue = set()
|
||||||
|
|
||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user