How to use the djet.testcases.MiddlewareType.PROCESS_REQUEST function in djet

To help you get started, we’ve selected a few djet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sunscrapers / djet / djet / testcases.py View on Github external
def _load_old_middleware(self):
        middleware_classes = self.middleware_classes or []
        for mw_class in middleware_classes:
            mw_class, mw_types = self._unpack_middleware(mw_class)
            mw_instance = mw_class()

            if self._should_add_middleware(mw_instance, mw_types, MiddlewareType.PROCESS_REQUEST):
                self._request_middleware.append(mw_instance.process_request)
            if self._should_add_middleware(mw_instance, mw_types, MiddlewareType.PROCESS_VIEW):
                self._view_middleware.append(mw_instance.process_view)
            if self._should_add_middleware(mw_instance, mw_types, MiddlewareType.PROCESS_TEMPLATE_RESPONSE):
                self._template_response_middleware.insert(0, mw_instance.process_template_response)
            if self._should_add_middleware(mw_instance, mw_types, MiddlewareType.PROCESS_RESPONSE):
                self._response_middleware.insert(0, mw_instance.process_response)
            if self._should_add_middleware(mw_instance, mw_types, MiddlewareType.PROCESS_EXCEPTION):
                self._exception_middleware.insert(0, mw_instance.process_exception)