| 62 | |
| 63 | @classmethod |
| 64 | def as_view(cls, name: str, *class_args: Any, **class_kwargs: Any) -> RouteCallable: |
| 65 | if cls.init_every_request: |
| 66 | |
| 67 | async def view(**kwargs: Any) -> ResponseReturnValue: |
| 68 | self = view.view_class(*class_args, **class_kwargs) # type: ignore |
| 69 | return await current_app.ensure_async(self.dispatch_request)(**kwargs) |
| 70 | |
| 71 | else: |
| 72 | self = cls(*class_args, **class_kwargs) |
| 73 | |
| 74 | async def view(**kwargs: Any) -> ResponseReturnValue: |
| 75 | return await current_app.ensure_async(self.dispatch_request)(**kwargs) |
| 76 | |
| 77 | if cls.decorators: |
| 78 | view.__name__ = name |
| 79 | view.__module__ = cls.__module__ |
| 80 | for decorator in cls.decorators: |
| 81 | view = decorator(view) |
| 82 | |
| 83 | view.view_class: type[View] = cls # type: ignore |
| 84 | view.__name__ = name |
| 85 | view.__doc__ = cls.__doc__ |
| 86 | view.__module__ = cls.__module__ |
| 87 | view.methods = cls.methods # type: ignore |
| 88 | view.provide_automatic_options = cls.provide_automatic_options # type: ignore |
| 89 | return view |
| 90 | |
| 91 | |
| 92 | class MethodView(View): |