plain 0.2.5__py3-none-any.whl → 0.3.1__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.
@@ -1,4 +1,3 @@
1
- from plain.assets.urls import get_asset_url
2
1
  from plain.paginator import Paginator
3
2
  from plain.utils import timezone
4
3
 
@@ -10,8 +9,16 @@ def url(viewname, *args, **kwargs):
10
9
  return reverse(viewname, args=args, kwargs=kwargs)
11
10
 
12
11
 
12
+ def asset(url_path):
13
+ # An explicit callable we can control, but also delay the import of asset.urls->views->templates
14
+ # for circular import reasons
15
+ from plain.assets.urls import get_asset_url
16
+
17
+ return get_asset_url(url_path)
18
+
19
+
13
20
  default_globals = {
14
- "asset": get_asset_url,
21
+ "asset": asset,
15
22
  "url": url,
16
23
  "Paginator": Paginator,
17
24
  "now": timezone.now,
plain/test/client.py CHANGED
@@ -2,7 +2,6 @@ import json
2
2
  import mimetypes
3
3
  import os
4
4
  import sys
5
- from copy import copy
6
5
  from functools import partial
7
6
  from http import HTTPStatus
8
7
  from http.cookies import SimpleCookie
@@ -196,19 +195,6 @@ class ClientHandler(BaseHandler):
196
195
  return response
197
196
 
198
197
 
199
- def store_rendered_templates(store, signal, sender, template, context, **kwargs):
200
- """
201
- Store templates and contexts that are rendered.
202
-
203
- The context is copied so that it is an accurate representation at the time
204
- of rendering.
205
- """
206
- store.setdefault("templates", []).append(template)
207
- if "context" not in store:
208
- store["context"] = ContextList()
209
- store["context"].append(copy(context))
210
-
211
-
212
198
  def encode_multipart(boundary, data):
213
199
  """
214
200
  Encode multipart POST data from a dictionary of form values.
@@ -683,12 +669,6 @@ class Client(ClientMixin, RequestFactory):
683
669
  """
684
670
  environ = self._base_environ(**request)
685
671
 
686
- # Curry a data dictionary into an instance of the template renderer
687
- # callback function.
688
- data = {}
689
- partial(store_rendered_templates, data)
690
- "template-render-%s" % id(request)
691
- # signals.template_rendered.connect(on_template_render, dispatch_uid=signal_uid)
692
672
  # Capture exceptions created by the handler.
693
673
  exception_uid = "request-exception-%s" % id(request)
694
674
  got_request_exception.connect(self.store_exc_info, dispatch_uid=exception_uid)
@@ -702,20 +682,18 @@ class Client(ClientMixin, RequestFactory):
702
682
  # Save the client and request that stimulated the response.
703
683
  response.client = self
704
684
  response.request = request
705
- # Add any rendered template detail to the response.
706
- response.templates = data.get("templates", [])
707
- response.context = data.get("context")
708
685
  response.json = partial(self._parse_json, response)
686
+
687
+ # If the request had a user attached, make it available on the response.
688
+ if hasattr(response.wsgi_request, "user"):
689
+ response.user = response.wsgi_request.user
690
+
709
691
  # Attach the ResolverMatch instance to the response.
710
692
  urlconf = getattr(response.wsgi_request, "urlconf", None)
711
693
  response.resolver_match = SimpleLazyObject(
712
694
  lambda: resolve(request["PATH_INFO"], urlconf=urlconf),
713
695
  )
714
- # Flatten a single context. Not really necessary anymore thanks to the
715
- # __getattr__ flattening in ContextList, but has some edge case
716
- # backwards compatibility implications.
717
- if response.context and len(response.context) == 1:
718
- response.context = response.context[0]
696
+
719
697
  # Update persistent cookie data.
720
698
  if response.cookies:
721
699
  self.cookies.update(response.cookies)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: plain
3
- Version: 0.2.5
3
+ Version: 0.3.1
4
4
  Summary: A web framework for building products with Python.
5
5
  Author: Dave Gaeddert
6
6
  Author-email: dave.gaeddert@dropseed.dev
@@ -98,10 +98,10 @@ plain/templates/jinja/__init__.py,sha256=1VAyXRHf2hDPniZfnKhiMWsOp4Gkg0Ss1xmAbuv
98
98
  plain/templates/jinja/defaults.py,sha256=AhGxp8X4UNC6CRD0XygQDV3ZeIs4KH2NaCjPtlgFeL0,3770
99
99
  plain/templates/jinja/extensions.py,sha256=AEmmmHDbdRW8fhjYDzq9eSSNbp9WHsXenD8tPthjc0s,1351
100
100
  plain/templates/jinja/filters.py,sha256=3KJKKbxcv9dLzUDWPcaa88k3NU2m1GG3iMIgFhzXrBA,860
101
- plain/templates/jinja/globals.py,sha256=MRhkTVVH2iKWc_GPX5E2uoafBV-tDVxyY58d_S4Zgwo,479
101
+ plain/templates/jinja/globals.py,sha256=qhvQuikkRkOTpHSW5FwdsvoViJNlRgHq3-O7ZyeajsE,669
102
102
  plain/test/README.md,sha256=Zso3Ir7a8vQerzKB6egjROQWkpveLAbscn7VTROPAiU,37
103
103
  plain/test/__init__.py,sha256=rXe88Y602NP8DBnReSyXb7dUzKoWweLuT43j-qwOUl4,138
104
- plain/test/client.py,sha256=w8QxRE04ozCyF5TZRxrtg-R9ECiZ0VV105t9Ty89cXg,32412
104
+ plain/test/client.py,sha256=cu43S-NL606VERUYi7NjvzIrVchlNLHqcKro7pnYmS4,31385
105
105
  plain/urls/README.md,sha256=pWnCvgYkWN7rG7hSyBOtX4ZUP3iO7FhqM6lvwwYll6c,33
106
106
  plain/urls/__init__.py,sha256=3UzwIufXjIks2K_X_Vms2MV19IqvyPLrXUeHU3WP47c,753
107
107
  plain/urls/base.py,sha256=ECaOCEXs1ygKn4k1mt5XxSNPNlg5raJvx0aPaj7DFfE,3719
@@ -152,8 +152,8 @@ plain/views/objects.py,sha256=9QBYyb8PgkRirXCQ8-Pms4_yMzP37dfeL30hWRYmtZg,7909
152
152
  plain/views/redirect.py,sha256=KLnlktzK6ZNMTlaEiZpMKQMEP5zeTgGLJ9BIkIJfwBo,1733
153
153
  plain/views/templates.py,sha256=nF9CcdhhjAyp3LB0RrSYnBaHpHzMfPSw719RCdcXk7o,2007
154
154
  plain/wsgi.py,sha256=R6k5FiAElvGDApEbMPTT0MPqSD7n2e2Az5chQqJZU0I,236
155
- plain-0.2.5.dist-info/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
156
- plain-0.2.5.dist-info/METADATA,sha256=KyaK66wyLHe9OHXObllwbTbUPmyk6jNqTGRo-yOJkkI,2716
157
- plain-0.2.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
158
- plain-0.2.5.dist-info/entry_points.txt,sha256=7O1RZTmMasKYB73bfqQcTwIhsXo7RjEIKv2WbtTtOIM,39
159
- plain-0.2.5.dist-info/RECORD,,
155
+ plain-0.3.1.dist-info/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
156
+ plain-0.3.1.dist-info/METADATA,sha256=jqe-VkpbsAVz8oO9xeOuDmZPkvszIdUfXzgTyxr0yJU,2716
157
+ plain-0.3.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
158
+ plain-0.3.1.dist-info/entry_points.txt,sha256=7O1RZTmMasKYB73bfqQcTwIhsXo7RjEIKv2WbtTtOIM,39
159
+ plain-0.3.1.dist-info/RECORD,,
File without changes
File without changes