@@ -50,7 +50,7 @@ def __call__(
5050 * args ,
5151 ** kwargs ,
5252 )
53- return self .as_view (request , * args , context = context , ** kwargs )
53+ return self .as_view (request , * args , route_context = context , ** kwargs )
5454
5555 def _get_required_api_func_signature (self ) -> Tuple :
5656 skip_parameters = ["self" , "request" ]
@@ -77,12 +77,14 @@ def _resolve_api_func_signature_(self, context_func: Callable) -> Callable:
7777 def get_view_function (self ) -> Callable :
7878 def as_view (
7979 request : HttpRequest ,
80- context : Optional [RouteContext ] = None ,
80+ route_context : Optional [RouteContext ] = None ,
8181 * args : Any ,
8282 ** kwargs : Any ,
8383 ) -> Any :
84- context = context or cast (RouteContext , service_resolver (RouteContext ))
85- with self ._prep_controller_route_execution (context , ** kwargs ) as ctx :
84+ _route_context = route_context or cast (
85+ RouteContext , service_resolver (RouteContext )
86+ )
87+ with self ._prep_controller_route_execution (_route_context , ** kwargs ) as ctx :
8688 ctx .controller_instance .check_permissions ()
8789 result = self .route .view_func (
8890 ctx .controller_instance , * args , ** ctx .view_func_kwargs
@@ -134,14 +136,14 @@ def get_route_execution_context(
134136
135137 @contextmanager
136138 def _prep_controller_route_execution (
137- self , context : RouteContext , ** kwargs : Any
139+ self , route_context : RouteContext , ** kwargs : Any
138140 ) -> Iterator [RouteFunctionContext ]:
139141 controller_instance = self ._get_controller_instance ()
140- controller_instance .context = context
142+ controller_instance .context = route_context
141143
142- api_func_kwargs = dict (** kwargs )
144+ api_func_kwargs = dict (kwargs )
143145 if self .has_request_param :
144- api_func_kwargs .update (request = context .request )
146+ api_func_kwargs .update (request = route_context .request )
145147 try :
146148 yield RouteFunctionContext (
147149 controller_instance = controller_instance , ** api_func_kwargs
@@ -164,14 +166,16 @@ class AsyncRouteFunction(RouteFunction):
164166 def get_view_function (self ) -> Callable :
165167 async def as_view (
166168 request : HttpRequest ,
167- context : Optional [RouteContext ] = None ,
169+ route_context : Optional [RouteContext ] = None ,
168170 * args : Any ,
169171 ** kwargs : Any ,
170172 ) -> Any :
171173 from asgiref .sync import sync_to_async
172174
173- context = context or cast (RouteContext , service_resolver (RouteContext ))
174- with self ._prep_controller_route_execution (context , ** kwargs ) as ctx :
175+ _route_context = route_context or cast (
176+ RouteContext , service_resolver (RouteContext )
177+ )
178+ with self ._prep_controller_route_execution (_route_context , ** kwargs ) as ctx :
175179 await sync_to_async (ctx .controller_instance .check_permissions )()
176180 result = await self .route .view_func (
177181 ctx .controller_instance , * args , ** ctx .view_func_kwargs
@@ -201,4 +205,4 @@ async def __call__(
201205 * args ,
202206 ** kwargs ,
203207 )
204- return await self .as_view (request , * args , context = context , ** kwargs )
208+ return await self .as_view (request , * args , route_context = context , ** kwargs )
0 commit comments