@@ -19,6 +19,17 @@ class RouteContext:
1919 APIController Context which will be available to the class instance when handling request
2020 """
2121
22+ __slots__ = [
23+ "permission_classes" ,
24+ "request" ,
25+ "response" ,
26+ "args" ,
27+ "kwargs" ,
28+ "_api" ,
29+ "_view_signature" ,
30+ "_has_computed_route_parameters" ,
31+ ]
32+
2233 permission_classes : PermissionType
2334 request : Union [Any , HttpRequest , None ]
2435 response : Union [Any , HttpResponse , None ]
@@ -40,8 +51,8 @@ def __init__(
4051 self .args : List [Any ] = args or []
4152 self .kwargs : DictStrAny = kwargs or {}
4253 self .permission_classes : PermissionType = permission_classes or []
43- self .api = api
44- self .view_signature = view_signature
54+ self ._api = api
55+ self ._view_signature = view_signature
4556 self ._has_computed_route_parameters = False
4657
4758 @property
@@ -51,7 +62,7 @@ def has_computed_route_parameters(self) -> bool:
5162 def compute_route_parameters (
5263 self ,
5364 ) -> None :
54- if self .view_signature is None or self .api is None :
65+ if self ._view_signature is None or self ._api is None :
5566 raise ImproperlyConfigured (
5667 "view_signature and api are required. "
5768 "Or you are taking an approach that is not supported "
@@ -62,9 +73,9 @@ def compute_route_parameters(
6273 return
6374
6475 values , errors = {}, []
65- for model in self .view_signature .models :
76+ for model in self ._view_signature .models :
6677 try :
67- data = model .resolve (self .request , self .api , self .kwargs )
78+ data = model .resolve (self .request , self ._api , self .kwargs )
6879 values .update (data )
6980 except pydantic .ValidationError as e :
7081 items = []
@@ -86,8 +97,8 @@ def compute_route_parameters(
8697 if errors :
8798 raise ValidationError (errors )
8899
89- if self .view_signature .response_arg :
90- values [self .view_signature .response_arg ] = self .response
100+ if self ._view_signature .response_arg :
101+ values [self ._view_signature .response_arg ] = self .response
91102
92103 self .kwargs .update (values )
93104 self ._has_computed_route_parameters = True
0 commit comments