plain 0.42.1__py3-none-any.whl → 0.42.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
plain/urls/resolvers.py CHANGED
@@ -103,7 +103,6 @@ class URLResolver:
103
103
  self.router = router
104
104
  self._reverse_dict = {}
105
105
  self._namespace_dict = {}
106
- self._app_dict = {}
107
106
  self._populated = False
108
107
  self._local = local()
109
108
 
@@ -132,7 +131,6 @@ class URLResolver:
132
131
  self._local.populating = True
133
132
  lookups = MultiValueDict()
134
133
  namespaces = {}
135
- packages = {}
136
134
  for url_pattern in reversed(self.url_patterns):
137
135
  p_pattern = url_pattern.pattern.regex.pattern
138
136
  p_pattern = p_pattern.removeprefix("^")
@@ -158,9 +156,6 @@ class URLResolver:
158
156
  else: # url_pattern is a URLResolver.
159
157
  url_pattern._populate()
160
158
  if url_pattern.namespace:
161
- packages.setdefault(url_pattern.namespace, []).append(
162
- url_pattern.namespace
163
- )
164
159
  namespaces[url_pattern.namespace] = (p_pattern, url_pattern)
165
160
  else:
166
161
  for name in url_pattern.reverse_dict:
@@ -189,13 +184,7 @@ class URLResolver:
189
184
  current_converters = url_pattern.pattern.converters
190
185
  sub_pattern.pattern.converters.update(current_converters)
191
186
  namespaces[namespace] = (p_pattern + prefix, sub_pattern)
192
- for (
193
- namespace,
194
- namespace_list,
195
- ) in url_pattern.app_dict.items():
196
- packages.setdefault(namespace, []).extend(namespace_list)
197
187
  self._namespace_dict = namespaces
198
- self._app_dict = packages
199
188
  self._reverse_dict = lookups
200
189
  self._populated = True
201
190
  finally:
@@ -213,12 +202,6 @@ class URLResolver:
213
202
  self._populate()
214
203
  return self._namespace_dict
215
204
 
216
- @property
217
- def app_dict(self):
218
- if not self._app_dict:
219
- self._populate()
220
- return self._app_dict
221
-
222
205
  @staticmethod
223
206
  def _join_route(route1, route2):
224
207
  """Join two routes, without the starting ^ in the second route."""
plain/urls/utils.py CHANGED
@@ -4,57 +4,38 @@ from .exceptions import NoReverseMatch
4
4
  from .resolvers import get_ns_resolver, get_resolver
5
5
 
6
6
 
7
- def reverse(viewname, *args, **kwargs):
7
+ def reverse(url_name: str, *args, **kwargs):
8
8
  resolver = get_resolver()
9
9
 
10
- if not isinstance(viewname, str):
11
- view = viewname
12
- else:
13
- *path, view = viewname.split(":")
14
-
15
- current_path = None
16
-
17
- resolved_path = []
18
- ns_pattern = ""
19
- ns_converters = {}
20
- for ns in path:
21
- current_ns = current_path.pop() if current_path else None
22
- # Lookup the name to see if it could be an app identifier.
23
- try:
24
- app_list = resolver.app_dict[ns]
25
- # Yes! Path part matches an app in the current Resolver.
26
- if current_ns and current_ns in app_list:
27
- # If we are reversing for a particular app, use that
28
- # namespace.
29
- ns = current_ns
30
- elif ns not in app_list:
31
- # The name isn't shared by one of the instances (i.e.,
32
- # the default) so pick the first instance as the default.
33
- ns = app_list[0]
34
- except KeyError:
35
- pass
36
-
37
- if ns != current_ns:
38
- current_path = None
39
-
40
- try:
41
- extra, resolver = resolver.namespace_dict[ns]
42
- resolved_path.append(ns)
43
- ns_pattern += extra
44
- ns_converters.update(resolver.pattern.converters)
45
- except KeyError as key:
46
- if resolved_path:
47
- raise NoReverseMatch(
48
- "{} is not a registered namespace inside '{}'".format(
49
- key, ":".join(resolved_path)
50
- )
10
+ *path, view = url_name.split(":")
11
+
12
+ current_path = None
13
+
14
+ resolved_path = []
15
+ ns_pattern = ""
16
+ ns_converters = {}
17
+ for ns in path:
18
+ current_ns = current_path.pop() if current_path else None
19
+
20
+ if ns != current_ns:
21
+ current_path = None
22
+
23
+ try:
24
+ extra, resolver = resolver.namespace_dict[ns]
25
+ resolved_path.append(ns)
26
+ ns_pattern += extra
27
+ ns_converters.update(resolver.pattern.converters)
28
+ except KeyError as key:
29
+ if resolved_path:
30
+ raise NoReverseMatch(
31
+ "{} is not a registered namespace inside '{}'".format(
32
+ key, ":".join(resolved_path)
51
33
  )
52
- else:
53
- raise NoReverseMatch(f"{key} is not a registered namespace")
54
- if ns_pattern:
55
- resolver = get_ns_resolver(
56
- ns_pattern, resolver, tuple(ns_converters.items())
57
- )
34
+ )
35
+ else:
36
+ raise NoReverseMatch(f"{key} is not a registered namespace")
37
+ if ns_pattern:
38
+ resolver = get_ns_resolver(ns_pattern, resolver, tuple(ns_converters.items()))
58
39
 
59
40
  return resolver.reverse(view, *args, **kwargs)
60
41
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain
3
- Version: 0.42.1
3
+ Version: 0.42.2
4
4
  Summary: A web framework for building products with Python.
5
5
  Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
6
6
  License-File: LICENSE
@@ -108,9 +108,9 @@ plain/urls/__init__.py,sha256=DFO2OL1IllHW5USPIb5uYvvzf_G-Bl0Qu1zrRLHmWyM,542
108
108
  plain/urls/converters.py,sha256=s2JZVOdzZC16lgobsI93hygcdH5L0Kj4742WEkXsVcs,1193
109
109
  plain/urls/exceptions.py,sha256=q4iPh3Aa-zHbA-tw8v6WyX1J1n5WdAady2xvxFuyXB0,114
110
110
  plain/urls/patterns.py,sha256=7DxL5LWq40lI4hFxAJ2I4MyA3HrbCmNx_dHOk8yYiK8,8259
111
- plain/urls/resolvers.py,sha256=3I10pLpLvhL4NamABJGH8e5Se6Iqa2y7V6hMAFQxVSg,13264
111
+ plain/urls/resolvers.py,sha256=sZsFQRPlPkogXIVSctZBXJaG0spJzuoJBmtOEZwIXXY,12630
112
112
  plain/urls/routers.py,sha256=iEsQtTpPNDDVn7r_BQX84FESGSjOeD5qgyO_ep5rzaU,2819
113
- plain/urls/utils.py,sha256=WiGq6hHI-5DLFOxCQTAZ2qm0J-UdGosLcjuxlfK6_Tg,2137
113
+ plain/urls/utils.py,sha256=lKxTX_A3XJpIH7FjlNYju108stY6-8Sw2uVdiSsxOKQ,1249
114
114
  plain/utils/README.md,sha256=hRRkcg4CxMX-zz8d4Bn6V2uJr_VKgTLurc1jY7QlEx8,198
115
115
  plain/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
116
116
  plain/utils/cache.py,sha256=iuvOTIfI1s857iVOAPNLK5lkzlrl0fIiBYaiUXWQu40,5303
@@ -146,8 +146,8 @@ plain/views/forms.py,sha256=ESZOXuo6IeYixp1RZvPb94KplkowRiwO2eGJCM6zJI0,2400
146
146
  plain/views/objects.py,sha256=GGbcfg_9fPZ-PiaBwIHG2e__8GfWDR7JQtQ15wTyiHg,5970
147
147
  plain/views/redirect.py,sha256=daq2cQIkdDF78bt43sjuZxRAyJm_t_SKw6tyPmiXPIc,1985
148
148
  plain/views/templates.py,sha256=SU1fO9gVMp-gEQHYeFplxvmgeMyrLgT8MJ12WNVmQC8,2085
149
- plain-0.42.1.dist-info/METADATA,sha256=IHizSykNDJ-Emw_cLUPeI9le20o129_Olts1xjYHakM,4297
150
- plain-0.42.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
151
- plain-0.42.1.dist-info/entry_points.txt,sha256=1Ys2lsSeMepD1vz8RSrJopna0RQfUd951vYvCRsvl6A,45
152
- plain-0.42.1.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
153
- plain-0.42.1.dist-info/RECORD,,
149
+ plain-0.42.2.dist-info/METADATA,sha256=-2ueX6bhRxFuPq7x4GDGiML7MsQ93dY2ORRZe-FrutM,4297
150
+ plain-0.42.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
151
+ plain-0.42.2.dist-info/entry_points.txt,sha256=1Ys2lsSeMepD1vz8RSrJopna0RQfUd951vYvCRsvl6A,45
152
+ plain-0.42.2.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
153
+ plain-0.42.2.dist-info/RECORD,,
File without changes