plain 0.22.2__tar.gz → 0.23.0__tar.gz
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-0.22.2 → plain-0.23.0}/PKG-INFO +1 -1
- {plain-0.22.2 → plain-0.23.0}/plain/urls/resolvers.py +13 -16
- {plain-0.22.2 → plain-0.23.0}/plain/urls/routers.py +25 -10
- {plain-0.22.2 → plain-0.23.0}/pyproject.toml +1 -1
- {plain-0.22.2 → plain-0.23.0}/tests/app/urls.py +1 -0
- {plain-0.22.2 → plain-0.23.0}/.gitignore +0 -0
- {plain-0.22.2 → plain-0.23.0}/LICENSE +0 -0
- {plain-0.22.2 → plain-0.23.0}/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/__main__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/assets/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/assets/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/assets/compile.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/assets/finders.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/assets/fingerprints.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/assets/urls.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/assets/views.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/cli/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/cli/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/cli/cli.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/cli/formatting.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/cli/packages.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/cli/print.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/cli/startup.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/csrf/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/csrf/middleware.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/csrf/views.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/debug.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/exceptions.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/forms/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/forms/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/forms/boundfield.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/forms/exceptions.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/forms/fields.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/forms/forms.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/http/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/http/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/http/cookie.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/http/multipartparser.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/http/request.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/http/response.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/files/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/files/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/files/base.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/files/locks.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/files/move.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/files/temp.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/files/uploadedfile.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/files/uploadhandler.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/files/utils.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/handlers/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/handlers/base.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/handlers/exception.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/handlers/wsgi.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/middleware/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/middleware/headers.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/middleware/https.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/internal/middleware/slash.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/json.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/logs/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/logs/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/logs/configure.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/logs/loggers.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/logs/utils.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/packages/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/packages/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/packages/config.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/packages/registry.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/paginator.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/preflight/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/preflight/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/preflight/files.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/preflight/messages.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/preflight/registry.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/preflight/security.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/preflight/urls.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/runtime/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/runtime/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/runtime/global_settings.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/runtime/user_settings.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/signals/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/signals/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/signals/dispatch/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/signals/dispatch/dispatcher.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/signals/dispatch/license.txt +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/signing.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/templates/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/templates/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/templates/core.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/templates/jinja/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/templates/jinja/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/templates/jinja/environments.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/templates/jinja/extensions.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/templates/jinja/filters.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/templates/jinja/globals.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/test/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/test/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/test/client.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/urls/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/urls/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/urls/converters.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/urls/exceptions.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/urls/patterns.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/urls/utils.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/_os.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/cache.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/connection.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/crypto.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/datastructures.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/dateformat.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/dateparse.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/dates.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/deconstruct.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/decorators.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/duration.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/email.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/encoding.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/functional.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/hashable.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/html.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/http.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/inspect.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/ipv6.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/itercompat.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/module_loading.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/regex_helper.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/safestring.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/text.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/timesince.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/timezone.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/utils/tree.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/validators.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/views/README.md +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/views/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/views/base.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/views/csrf.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/views/errors.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/views/exceptions.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/views/forms.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/views/objects.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/views/redirect.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/views/templates.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/plain/wsgi.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/tests/.bolt/assets_collected/assets.json +0 -0
- {plain-0.22.2 → plain-0.23.0}/tests/.gitignore +0 -0
- {plain-0.22.2 → plain-0.23.0}/tests/app/.gitignore +0 -0
- {plain-0.22.2 → plain-0.23.0}/tests/app/settings.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/tests/app/test/__init__.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/tests/app/test/default_settings.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/tests/conftest.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/tests/test_cli.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/tests/test_runtime.py +0 -0
- {plain-0.22.2 → plain-0.23.0}/tests/test_wsgi.py +0 -0
@@ -16,7 +16,6 @@ from urllib.parse import quote
|
|
16
16
|
from plain.preflight.urls import check_resolver
|
17
17
|
from plain.runtime import settings
|
18
18
|
from plain.utils.datastructures import MultiValueDict
|
19
|
-
from plain.utils.functional import cached_property
|
20
19
|
from plain.utils.http import RFC3986_SUBDELIMS, escape_leading_slashes
|
21
20
|
from plain.utils.regex_helper import normalize
|
22
21
|
|
@@ -106,7 +105,7 @@ def _get_cached_resolver(urls_module):
|
|
106
105
|
urls_module = import_module(urls_module)
|
107
106
|
|
108
107
|
router = routers_registry.get_module_router(urls_module)
|
109
|
-
return URLResolver(pattern=RegexPattern(r"^/"),
|
108
|
+
return URLResolver(pattern=RegexPattern(r"^/"), router=router)
|
110
109
|
|
111
110
|
|
112
111
|
@functools.cache
|
@@ -120,16 +119,18 @@ def get_ns_resolver(ns_pattern, resolver, converters):
|
|
120
119
|
pattern.converters = dict(converters)
|
121
120
|
|
122
121
|
class _NestedRouter(RouterBase):
|
122
|
+
namespace = ""
|
123
123
|
urls = resolver.url_patterns
|
124
124
|
|
125
|
-
ns_resolver = URLResolver(pattern=pattern,
|
125
|
+
ns_resolver = URLResolver(pattern=pattern, router=_NestedRouter())
|
126
126
|
|
127
127
|
class _NamespacedRouter(RouterBase):
|
128
|
+
namespace = ""
|
128
129
|
urls = [ns_resolver]
|
129
130
|
|
130
131
|
return URLResolver(
|
131
132
|
pattern=RegexPattern(r"^/"),
|
132
|
-
|
133
|
+
router=_NamespacedRouter(),
|
133
134
|
)
|
134
135
|
|
135
136
|
|
@@ -138,18 +139,23 @@ class URLResolver:
|
|
138
139
|
self,
|
139
140
|
*,
|
140
141
|
pattern,
|
141
|
-
|
142
|
+
router,
|
142
143
|
):
|
143
144
|
self.pattern = pattern
|
144
|
-
self.
|
145
|
+
self.router = router
|
145
146
|
self._reverse_dict = {}
|
146
147
|
self._namespace_dict = {}
|
147
148
|
self._app_dict = {}
|
148
149
|
self._populated = False
|
149
150
|
self._local = local()
|
150
151
|
|
152
|
+
# Set these immediately, in part so we can find routers
|
153
|
+
# where the attributes weren't set correctly.
|
154
|
+
self.namespace = self.router.namespace
|
155
|
+
self.url_patterns = self.router.urls
|
156
|
+
|
151
157
|
def __repr__(self):
|
152
|
-
return f"<{self.__class__.__name__} {repr(self.
|
158
|
+
return f"<{self.__class__.__name__} {repr(self.router)} ({self.namespace}) {self.pattern.describe()}>"
|
153
159
|
|
154
160
|
def check(self):
|
155
161
|
messages = []
|
@@ -313,15 +319,6 @@ class URLResolver:
|
|
313
319
|
raise Resolver404({"tried": tried, "path": new_path})
|
314
320
|
raise Resolver404({"path": path})
|
315
321
|
|
316
|
-
@cached_property
|
317
|
-
def url_patterns(self):
|
318
|
-
# Don't need to instantiate the class because they are just class attributes for now.
|
319
|
-
return self.router_class.urls
|
320
|
-
|
321
|
-
@cached_property
|
322
|
-
def namespace(self):
|
323
|
-
return self.router_class.namespace
|
324
|
-
|
325
322
|
def reverse(self, lookup_view, *args, **kwargs):
|
326
323
|
if args and kwargs:
|
327
324
|
raise ValueError("Don't mix *args and **kwargs in call to reverse()!")
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import re
|
2
|
-
from abc import ABC
|
3
2
|
from types import ModuleType
|
4
3
|
from typing import TYPE_CHECKING
|
5
4
|
|
@@ -14,9 +13,16 @@ if TYPE_CHECKING:
|
|
14
13
|
from plain.views import View
|
15
14
|
|
16
15
|
|
17
|
-
class RouterBase
|
18
|
-
|
19
|
-
|
16
|
+
class RouterBase:
|
17
|
+
"""
|
18
|
+
Base class for defining url patterns.
|
19
|
+
|
20
|
+
A namespace is required, and generally recommended,
|
21
|
+
except for the root router in app.urls where it is typically "".
|
22
|
+
"""
|
23
|
+
|
24
|
+
namespace: str
|
25
|
+
urls: list
|
20
26
|
|
21
27
|
|
22
28
|
class RoutersRegistry:
|
@@ -26,9 +32,12 @@ class RoutersRegistry:
|
|
26
32
|
self._routers = {}
|
27
33
|
|
28
34
|
def register_router(self, router_class):
|
35
|
+
router = (
|
36
|
+
router_class()
|
37
|
+
) # Don't necessarily need to instantiate it yet, but will likely add methods.
|
29
38
|
router_module_name = router_class.__module__
|
30
|
-
self._routers[router_module_name] =
|
31
|
-
return
|
39
|
+
self._routers[router_module_name] = router
|
40
|
+
return router
|
32
41
|
|
33
42
|
def get_module_router(self, module):
|
34
43
|
if isinstance(module, str):
|
@@ -62,17 +71,18 @@ def include(
|
|
62
71
|
# We were given an explicit list of sub-patterns,
|
63
72
|
# so we generate a router for it
|
64
73
|
class _IncludeRouter(RouterBase):
|
74
|
+
namespace = ""
|
65
75
|
urls = module_or_urls
|
66
76
|
|
67
|
-
return URLResolver(pattern=pattern,
|
77
|
+
return URLResolver(pattern=pattern, router=_IncludeRouter())
|
68
78
|
else:
|
69
79
|
# We were given a module, so we need to look up the router for that module
|
70
80
|
module = module_or_urls
|
71
|
-
|
81
|
+
router = routers_registry.get_module_router(module)
|
72
82
|
|
73
83
|
return URLResolver(
|
74
84
|
pattern=pattern,
|
75
|
-
|
85
|
+
router=router,
|
76
86
|
)
|
77
87
|
|
78
88
|
|
@@ -109,4 +119,9 @@ def path(route: str | re.Pattern, view: "View", *, name: str = "") -> URLPattern
|
|
109
119
|
|
110
120
|
|
111
121
|
routers_registry = RoutersRegistry()
|
112
|
-
|
122
|
+
|
123
|
+
|
124
|
+
def register_router(router_class):
|
125
|
+
"""Decorator to register a router class"""
|
126
|
+
routers_registry.register_router(router_class)
|
127
|
+
return router_class # Return the class, not the instance
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|