Make a generic request. Compose the scope dictionary and pass to the handler, return the result of the handler. Assume defaults for the query environment, which can be overridden using the arguments to the request.
(self, **request)
| 1423 | self.headers = None |
| 1424 | |
| 1425 | async def request(self, **request): |
| 1426 | """ |
| 1427 | Make a generic request. Compose the scope dictionary and pass to the |
| 1428 | handler, return the result of the handler. Assume defaults for the |
| 1429 | query environment, which can be overridden using the arguments to the |
| 1430 | request. |
| 1431 | """ |
| 1432 | scope = self._base_scope(**request) |
| 1433 | # Curry a data dictionary into an instance of the template renderer |
| 1434 | # callback function. |
| 1435 | data = {} |
| 1436 | on_template_render = partial(store_rendered_templates, data) |
| 1437 | signal_uid = "template-render-%s" % id(request) |
| 1438 | signals.template_rendered.connect(on_template_render, dispatch_uid=signal_uid) |
| 1439 | # Capture exceptions created by the handler. |
| 1440 | exception_uid = "request-exception-%s" % id(request) |
| 1441 | got_request_exception.connect(self.store_exc_info, dispatch_uid=exception_uid) |
| 1442 | try: |
| 1443 | response = await self.handler(scope) |
| 1444 | finally: |
| 1445 | signals.template_rendered.disconnect(dispatch_uid=signal_uid) |
| 1446 | got_request_exception.disconnect(dispatch_uid=exception_uid) |
| 1447 | # Check for signaled exceptions. |
| 1448 | self.check_exception(response) |
| 1449 | # Save the client and request that stimulated the response. |
| 1450 | response.client = self |
| 1451 | response.request = request |
| 1452 | # Add any rendered template detail to the response. |
| 1453 | response.templates = data.get("templates", []) |
| 1454 | response.context = data.get("context") |
| 1455 | response.json = partial(self._parse_json, response) |
| 1456 | # Attach the ResolverMatch instance to the response. |
| 1457 | urlconf = getattr(response.asgi_request, "urlconf", None) |
| 1458 | response.resolver_match = SimpleLazyObject( |
| 1459 | lambda: resolve(request["path"], urlconf=urlconf), |
| 1460 | ) |
| 1461 | # Flatten a single context. Not really necessary anymore thanks to the |
| 1462 | # __getattr__ flattening in ContextList, but has some edge case |
| 1463 | # backwards compatibility implications. |
| 1464 | if response.context and len(response.context) == 1: |
| 1465 | response.context = response.context[0] |
| 1466 | # Update persistent cookie data. |
| 1467 | if response.cookies: |
| 1468 | self.cookies.update(response.cookies) |
| 1469 | return response |
| 1470 | |
| 1471 | async def get( |
| 1472 | self, |
nothing calls this directly
no test coverage detected