plain 0.2.4__py3-none-any.whl → 0.3.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/views.py CHANGED
@@ -128,10 +128,8 @@ class AssetView(View):
128
128
  headers["Vary"] = vary + ", Accept-Encoding"
129
129
 
130
130
  # If the file is compressed, tell the browser
131
- if path.endswith(".gz"):
132
- headers.setdefault("Content-Encoding", "gzip")
133
- elif path.endswith(".br"):
134
- headers.setdefault("Content-Encoding", "br")
131
+ if encoding := mimetypes.guess_type(path)[1]:
132
+ headers.setdefault("Content-Encoding", encoding)
135
133
 
136
134
  is_immutable = self.is_immutable(path)
137
135
 
@@ -151,6 +149,12 @@ class AssetView(View):
151
149
  if etag := self.get_etag(path):
152
150
  headers.setdefault("ETag", etag)
153
151
 
152
+ if "Content-Disposition" in headers:
153
+ # This header messes up Safari...
154
+ # https://github.com/evansd/whitenoise/commit/93657cf88e14b919cb726864814617a6a639e507
155
+ # At some point, should probably look at not using FileResponse at all?
156
+ del headers["Content-Disposition"]
157
+
154
158
  return headers
155
159
 
156
160
  def is_immutable(self, path):
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.4
3
+ Version: 0.3.0
4
4
  Summary: A web framework for building products with Python.
5
5
  Author: Dave Gaeddert
6
6
  Author-email: dave.gaeddert@dropseed.dev
@@ -6,7 +6,7 @@ plain/assets/compile.py,sha256=lsnciN85YjHe6d8VIKJi1L8r7NGHNzMOe9L87wObM5I,3287
6
6
  plain/assets/finders.py,sha256=WEKAnXTmpuQ7UKLZz7vHPrKFdDOkuZSP6_JTKmIxrKg,1268
7
7
  plain/assets/fingerprints.py,sha256=1NKAnnXVlncY5iimXztr0NL3RIjBKsNlZRIe6nmItJc,931
8
8
  plain/assets/urls.py,sha256=ZTIoM1Zq35JaXZ3wFhXhfGa7VoITDNlH9i5RS0R5xow,933
9
- plain/assets/views.py,sha256=iVJEmXEDeud94z86OCtWLgMRTY3j6CIxaqHiAT7Ogls,8920
9
+ plain/assets/views.py,sha256=dhjIpMu0GDR_VGbXM90_6RnC84C2C4bFv1RxDVklGBk,9173
10
10
  plain/cli/README.md,sha256=bEp9B9C92YEa44wN2IywTmNZsYBv_uGq9AS_bBiAGdY,2580
11
11
  plain/cli/__init__.py,sha256=9ByBOIdM8DebChjNz-RH2atdz4vWe8somlwNEsbhwh4,40
12
12
  plain/cli/cli.py,sha256=JyPNQGlczqCyLxZq5Jh_591rKpBMN91JHGXdaTuPWJ0,14841
@@ -101,7 +101,7 @@ plain/templates/jinja/filters.py,sha256=3KJKKbxcv9dLzUDWPcaa88k3NU2m1GG3iMIgFhzX
101
101
  plain/templates/jinja/globals.py,sha256=MRhkTVVH2iKWc_GPX5E2uoafBV-tDVxyY58d_S4Zgwo,479
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.4.dist-info/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
156
- plain-0.2.4.dist-info/METADATA,sha256=jIUR5xsnJL-whX8iOKzKbvkOhWsQGurVk6_gJEyDJ3g,2716
157
- plain-0.2.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
158
- plain-0.2.4.dist-info/entry_points.txt,sha256=7O1RZTmMasKYB73bfqQcTwIhsXo7RjEIKv2WbtTtOIM,39
159
- plain-0.2.4.dist-info/RECORD,,
155
+ plain-0.3.0.dist-info/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
156
+ plain-0.3.0.dist-info/METADATA,sha256=Z7t7-Jdot0U9cymStFyaaItjoTsk8Ls8lSEu4pkzJ7Y,2716
157
+ plain-0.3.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
158
+ plain-0.3.0.dist-info/entry_points.txt,sha256=7O1RZTmMasKYB73bfqQcTwIhsXo7RjEIKv2WbtTtOIM,39
159
+ plain-0.3.0.dist-info/RECORD,,
File without changes
File without changes