Skip to content

Commit 714d934

Browse files
author
Kenny Putman
committed
update InertiaRequest to inherit from HttpRequest using super()
1 parent 2721940 commit 714d934

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

inertia/http.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from .prop_classes import DeferredProp, IgnoreOnFirstLoadProp, MergeableProp
1212
from .settings import settings
1313

14-
1514
INERTIA_REQUEST_ENCRYPT_HISTORY = "_inertia_encrypt_history"
1615
INERTIA_SESSION_CLEAR_HISTORY = "_inertia_clear_history"
1716

@@ -21,18 +20,19 @@
2120

2221
class InertiaRequest(HttpRequest):
2322
def __init__(self, request):
24-
self.request = request
25-
26-
def __getattr__(self, name):
27-
return getattr(self.request, name)
23+
super().__init__()
24+
self.__dict__.update(request.__dict__)
2825

2926
@property
3027
def headers(self):
31-
return self.request.headers
28+
return super().headers
3229

3330
@property
3431
def inertia(self):
35-
return self.request.inertia.all() if hasattr(self.request, "inertia") else {}
32+
inertia_attr = self.__dict__.get("inertia")
33+
return (
34+
inertia_attr.all() if inertia_attr and hasattr(inertia_attr, "all") else {}
35+
)
3636

3737
def is_a_partial_render(self, component):
3838
return (
@@ -52,7 +52,7 @@ def is_inertia(self):
5252
def should_encrypt_history(self):
5353
return validate_type(
5454
getattr(
55-
self.request,
55+
self,
5656
INERTIA_REQUEST_ENCRYPT_HISTORY,
5757
settings.INERTIA_ENCRYPT_HISTORY,
5858
),

0 commit comments

Comments
 (0)