MCPcopy
hub / github.com/django/django / ResolverMatch

Class ResolverMatch

django/urls/resolvers.py:34–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32
33
34class ResolverMatch:
35 def __init__(
36 self,
37 func,
38 args,
39 kwargs,
40 url_name=None,
41 app_names=None,
42 namespaces=None,
43 route=None,
44 tried=None,
45 captured_kwargs=None,
46 extra_kwargs=None,
47 ):
48 self.func = func
49 self.args = args
50 self.kwargs = kwargs
51 self.url_name = url_name
52 self.route = route
53 self.tried = tried
54 self.captured_kwargs = captured_kwargs
55 self.extra_kwargs = extra_kwargs
56
57 # If a URLRegexResolver doesn't have a namespace or app_name, it passes
58 # in an empty value.
59 self.app_names = [x for x in app_names if x] if app_names else []
60 self.app_name = ":".join(self.app_names)
61 self.namespaces = [x for x in namespaces if x] if namespaces else []
62 self.namespace = ":".join(self.namespaces)
63
64 if hasattr(func, "view_class"):
65 func = func.view_class
66 if not hasattr(func, "__name__"):
67 # A class-based view
68 self._func_path = func.__class__.__module__ + "." + func.__class__.__name__
69 else:
70 # A function-based view
71 self._func_path = func.__module__ + "." + func.__name__
72
73 view_path = url_name or self._func_path
74 self.view_name = ":".join([*self.namespaces, view_path])
75
76 def __getitem__(self, index):
77 return (self.func, self.args, self.kwargs)[index]
78
79 def __repr__(self):
80 if isinstance(self.func, functools.partial):
81 func = repr(self.func)
82 else:
83 func = self._func_path
84 return (
85 "ResolverMatch(func=%s, args=%r, kwargs=%r, url_name=%r, "
86 "app_names=%r, namespaces=%r, route=%r%s%s)"
87 % (
88 func,
89 self.args,
90 self.kwargs,
91 self.url_name,

Callers 2

resolveMethod · 0.85
resolveMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected