plain 0.42.1__py3-none-any.whl → 0.43.0__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/assets/compile.py CHANGED
@@ -2,7 +2,7 @@ import gzip
2
2
  import os
3
3
  import shutil
4
4
 
5
- from plain.runtime import settings
5
+ from plain.runtime import PLAIN_TEMP_PATH
6
6
 
7
7
  from .finders import iter_assets
8
8
  from .fingerprints import AssetsFingerprintsManifest, get_file_fingerprint
@@ -46,7 +46,7 @@ def get_compiled_path():
46
46
 
47
47
  There's no reason currently for this to be a user-facing setting.
48
48
  """
49
- return settings.PLAIN_TEMP_PATH / "assets" / "compiled"
49
+ return PLAIN_TEMP_PATH / "assets" / "compiled"
50
50
 
51
51
 
52
52
  def compile_assets(*, target_dir, keep_original, fingerprint, compress):
@@ -2,7 +2,7 @@ import hashlib
2
2
  import json
3
3
  from functools import cache
4
4
 
5
- from plain.runtime import settings
5
+ from plain.runtime import PLAIN_TEMP_PATH
6
6
 
7
7
  FINGERPRINT_LENGTH = 7
8
8
 
@@ -13,7 +13,7 @@ class AssetsFingerprintsManifest(dict):
13
13
  """
14
14
 
15
15
  def __init__(self):
16
- self.path = settings.PLAIN_TEMP_PATH / "assets" / "fingerprints.json"
16
+ self.path = PLAIN_TEMP_PATH / "assets" / "fingerprints.json"
17
17
 
18
18
  def load(self):
19
19
  if self.path.exists():
plain/runtime/__init__.py CHANGED
@@ -13,6 +13,7 @@ except importlib.metadata.PackageNotFoundError:
13
13
 
14
14
  # Made available without setup or settings
15
15
  APP_PATH = Path.cwd() / "app"
16
+ PLAIN_TEMP_PATH = Path.cwd() / ".plain"
16
17
 
17
18
  # from plain.runtime import settings
18
19
  settings = Settings()
@@ -3,18 +3,12 @@ Default Plain settings. Override these with settings in the module pointed to
3
3
  by the PLAIN_SETTINGS_MODULE environment variable.
4
4
  """
5
5
 
6
- from pathlib import Path
7
-
8
- from plain.runtime import APP_PATH as default_app_path
9
-
10
6
  ####################
11
7
  # CORE #
12
8
  ####################
13
9
 
14
10
  DEBUG: bool = False
15
11
 
16
- PLAIN_TEMP_PATH: Path = default_app_path.parent / ".plain"
17
-
18
12
  # Hosts/domain names that are valid for this site.
19
13
  # "*" matches anything, ".example.com" matches example.com and all subdomains
20
14
  ALLOWED_HOSTS: list[str] = []
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.43.0
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
@@ -9,9 +9,9 @@ plain/validators.py,sha256=TePzFHzwR4JXUAZ_Y2vC6mkKgVxHX3QBXI6Oex0rV8c,19236
9
9
  plain/wsgi.py,sha256=R6k5FiAElvGDApEbMPTT0MPqSD7n2e2Az5chQqJZU0I,236
10
10
  plain/assets/README.md,sha256=wgsmBK5vAHgFMZ010q7LTrgLq5BTfuPuuug5HLZ9GNw,3774
11
11
  plain/assets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- plain/assets/compile.py,sha256=rABDHj7k_YAIPVvS7JJLCukEgUhb7h5oz9ajt5fGirI,3298
12
+ plain/assets/compile.py,sha256=DT85ygnNcY2_7VeozdsQlBvA-DzV7enUIMO_igJ1PjY,3296
13
13
  plain/assets/finders.py,sha256=2k8QZAbfUbc1LykxbzdazTSB6xNxJZnsZaGhWbSFZZs,1452
14
- plain/assets/fingerprints.py,sha256=2LPHLUkoITMseLDmemTpBtMRDWCR2H5GAHjC6AN4gz0,1367
14
+ plain/assets/fingerprints.py,sha256=D-x0o49sUuWfx86BssDyo87yJCjWrV0go6JGPagvMAE,1365
15
15
  plain/assets/urls.py,sha256=zQUA8bAlh9qVqskPJJrqWd9DjvetOi5jPSqy4vUX0J4,1161
16
16
  plain/assets/views.py,sha256=T_0Qh6v9qBerEBYbhToigwOzsij-x1z_R-1zETQcIh0,9447
17
17
  plain/chores/README.md,sha256=Da8Nw8ZF7PlAE_iVb0AqJGbLOu0F6HC0cj1K451KBak,1946
@@ -82,8 +82,8 @@ plain/preflight/registry.py,sha256=wHLq6LSMkKunkxElBmNwzMzQx3tc6OGYeKyOOi0tuyQ,2
82
82
  plain/preflight/security.py,sha256=oxUZBp2M0bpBfUoLYepIxoex2Y90nyjlrL8XU8UTHYY,2438
83
83
  plain/preflight/urls.py,sha256=cQ-WnFa_5oztpKdtwhuIGb7pXEml__bHsjs1SWO2YNI,1468
84
84
  plain/runtime/README.md,sha256=S_FIOmSq8LkVQHh9Xm6s3EJWKTVdlSr5A_bNXgh02X8,4740
85
- plain/runtime/__init__.py,sha256=o2RVETiL8U0lMFBpbtfnxflhw_4MFllMV6CEpX3RqZs,1965
86
- plain/runtime/global_settings.py,sha256=Vi7jabMF-SBolkP5qx1nLnGoDt_kD1KT_wgtbjNlPHw,5580
85
+ plain/runtime/__init__.py,sha256=0Q7k0V-8OfmTaKC0paNvV4Lx92L1_J7xoEWQH9aO5y4,2005
86
+ plain/runtime/global_settings.py,sha256=bg7vnEDGU4mdMKFF7QnnhCFawAUjqqXiocryaOr6gsU,5438
87
87
  plain/runtime/user_settings.py,sha256=uRHHVfzUvHon91_fOKj7K2WaBYwJ1gCPLfeXqKj5CTs,10902
88
88
  plain/signals/README.md,sha256=FInfJXdVQkb7u93PvD8XgPbz_f6m0l2xIu_4PyttV1E,234
89
89
  plain/signals/__init__.py,sha256=eAs0kLqptuP6I31dWXeAqRNji3svplpAV4Ez6ktjwXM,131
@@ -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.43.0.dist-info/METADATA,sha256=OyYSGi2uaYzHFeHNmMYOzFiBtsurMXzDvJjug6-vTQg,4297
150
+ plain-0.43.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
151
+ plain-0.43.0.dist-info/entry_points.txt,sha256=1Ys2lsSeMepD1vz8RSrJopna0RQfUd951vYvCRsvl6A,45
152
+ plain-0.43.0.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
153
+ plain-0.43.0.dist-info/RECORD,,
File without changes