MCPcopy Create free account
hub / github.com/pallets/quart / as_view

Method as_view

src/quart/views.py:64–89  ·  view source on GitHub ↗
(cls, name: str, *class_args: Any, **class_kwargs: Any)

Source from the content-addressed store, hash-verified

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
92class MethodView(View):

Callers 4

test_viewFunction · 0.80
test_method_viewFunction · 0.80
test_view_decoratorsFunction · 0.80

Calls 1

decoratorFunction · 0.85

Tested by 4

test_viewFunction · 0.64
test_method_viewFunction · 0.64
test_view_decoratorsFunction · 0.64