plain 0.16.1__py3-none-any.whl → 0.17.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/http/response.py CHANGED
@@ -187,27 +187,6 @@ class ResponseBase:
187
187
  else ""
188
188
  )
189
189
 
190
- def __setitem__(self, header, value):
191
- self.headers[header] = value
192
-
193
- def __delitem__(self, header):
194
- del self.headers[header]
195
-
196
- def __getitem__(self, header):
197
- return self.headers[header]
198
-
199
- def has_header(self, header):
200
- """Case-insensitive check for a header."""
201
- return header in self.headers
202
-
203
- __contains__ = has_header
204
-
205
- def items(self):
206
- return self.headers.items()
207
-
208
- def get(self, header, alternate=None):
209
- return self.headers.get(header, alternate)
210
-
211
190
  def set_cookie(
212
191
  self,
213
192
  key,
@@ -272,10 +251,6 @@ class ResponseBase:
272
251
  raise ValueError('samesite must be "lax", "none", or "strict".')
273
252
  self.cookies[key]["samesite"] = samesite
274
253
 
275
- def setdefault(self, key, value):
276
- """Set a header unless it has already been set."""
277
- self.headers.setdefault(key, value)
278
-
279
254
  def set_signed_cookie(self, key, value, salt="", **kwargs):
280
255
  value = signing.get_cookie_signer(salt=key + salt).sign(value)
281
256
  return self.set_cookie(key, value, **kwargs)
@@ -587,14 +562,14 @@ class ResponseRedirectBase(Response):
587
562
 
588
563
  def __init__(self, redirect_to, *args, **kwargs):
589
564
  super().__init__(*args, **kwargs)
590
- self["Location"] = iri_to_uri(redirect_to)
565
+ self.headers["Location"] = iri_to_uri(redirect_to)
591
566
  parsed = urlparse(str(redirect_to))
592
567
  if parsed.scheme and parsed.scheme not in self.allowed_schemes:
593
568
  raise DisallowedRedirect(
594
569
  f"Unsafe redirect to URL with protocol '{parsed.scheme}'"
595
570
  )
596
571
 
597
- url = property(lambda self: self["Location"])
572
+ url = property(lambda self: self.headers["Location"])
598
573
 
599
574
  def __repr__(self):
600
575
  return (
@@ -627,7 +602,7 @@ class ResponseNotModified(Response):
627
602
 
628
603
  def __init__(self, *args, **kwargs):
629
604
  super().__init__(*args, **kwargs)
630
- del self["content-type"]
605
+ del self.headers["content-type"]
631
606
 
632
607
  @Response.content.setter
633
608
  def content(self, value):
@@ -663,14 +638,14 @@ class ResponseNotAllowed(Response):
663
638
 
664
639
  def __init__(self, permitted_methods, *args, **kwargs):
665
640
  super().__init__(*args, **kwargs)
666
- self["Allow"] = ", ".join(permitted_methods)
641
+ self.headers["Allow"] = ", ".join(permitted_methods)
667
642
 
668
643
  def __repr__(self):
669
644
  return "<%(cls)s [%(methods)s] status_code=%(status_code)d%(content_type)s>" % { # noqa: UP031
670
645
  "cls": self.__class__.__name__,
671
646
  "status_code": self.status_code,
672
647
  "content_type": self._content_type_for_repr,
673
- "methods": self["Allow"],
648
+ "methods": self.headers["Allow"],
674
649
  }
675
650
 
676
651
 
@@ -140,7 +140,7 @@ class WSGIHandler(base.BaseHandler):
140
140
 
141
141
  status = "%d %s" % (response.status_code, response.reason_phrase) # noqa: UP031
142
142
  response_headers = [
143
- *response.items(),
143
+ *response.headers.items(),
144
144
  *(("Set-Cookie", c.output(header="")) for c in response.cookies.values()),
145
145
  ]
146
146
  start_response(status, response_headers)
@@ -19,7 +19,7 @@ class DefaultHeadersMiddleware:
19
19
 
20
20
  # Add the Content-Length header to non-streaming responses if not
21
21
  # already set.
22
- if not response.streaming and not response.has_header("Content-Length"):
22
+ if not response.streaming and "Content-Length" not in response.headers:
23
23
  response.headers["Content-Length"] = str(len(response.content))
24
24
 
25
25
  return response
plain/test/client.py CHANGED
@@ -615,10 +615,10 @@ class ClientMixin:
615
615
 
616
616
  def _parse_json(self, response, **extra):
617
617
  if not hasattr(response, "_json"):
618
- if not JSON_CONTENT_TYPE_RE.match(response.get("Content-Type")):
618
+ if not JSON_CONTENT_TYPE_RE.match(response.headers.get("Content-Type")):
619
619
  raise ValueError(
620
620
  'Content-Type header is "{}", not "application/json"'.format(
621
- response.get("Content-Type")
621
+ response.headers.get("Content-Type")
622
622
  )
623
623
  )
624
624
  response._json = json.loads(
plain/utils/cache.py CHANGED
@@ -55,7 +55,7 @@ def patch_cache_control(response, **kwargs):
55
55
  return f"{t[0]}={t[1]}"
56
56
 
57
57
  cc = defaultdict(set)
58
- if response.get("Cache-Control"):
58
+ if response.headers.get("Cache-Control"):
59
59
  for field in cc_delim_re.split(response.headers["Cache-Control"]):
60
60
  directive, value = dictitem(field)
61
61
  if directive == "no-cache":
@@ -102,7 +102,7 @@ def get_max_age(response):
102
102
  Return the max-age from the response Cache-Control header as an integer,
103
103
  or None if it wasn't found or wasn't an integer.
104
104
  """
105
- if not response.has_header("Cache-Control"):
105
+ if "Cache-Control" not in response.headers:
106
106
  return
107
107
  cc = dict(
108
108
  _to_tuple(el) for el in cc_delim_re.split(response.headers["Cache-Control"])
@@ -146,7 +146,7 @@ def _not_modified(request, response=None):
146
146
  "Last-Modified",
147
147
  "Vary",
148
148
  ):
149
- if header in response:
149
+ if header in response.headers:
150
150
  new_response.headers[header] = response.headers[header]
151
151
 
152
152
  # Preserve cookies as per the cookie specification: "If a proxy server
@@ -278,7 +278,7 @@ def patch_response_headers(response, cache_timeout=None):
278
278
  cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
279
279
  if cache_timeout < 0:
280
280
  cache_timeout = 0 # Can't have max-age negative
281
- if not response.has_header("Expires"):
281
+ if "Expires" not in response.headers:
282
282
  response.headers["Expires"] = http_date(time.time() + cache_timeout)
283
283
  patch_cache_control(response, max_age=cache_timeout)
284
284
 
@@ -303,7 +303,7 @@ def patch_vary_headers(response, newheaders):
303
303
  # Note that we need to keep the original order intact, because cache
304
304
  # implementations may rely on the order of the Vary contents in, say,
305
305
  # computing an MD5 hash.
306
- if response.has_header("Vary"):
306
+ if "Vary" in response.headers:
307
307
  vary_headers = cc_delim_re.split(response.headers["Vary"])
308
308
  else:
309
309
  vary_headers = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain
3
- Version: 0.16.1
3
+ Version: 0.17.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
@@ -35,7 +35,7 @@ plain/http/__init__.py,sha256=DIsDRbBsCGa4qZgq-fUuQS0kkxfbTU_3KpIM9VvH04w,1067
35
35
  plain/http/cookie.py,sha256=11FnSG3Plo6T3jZDbPoCw7SKh9ExdBio3pTmIO03URg,597
36
36
  plain/http/multipartparser.py,sha256=k6BhpilFENQQ1cuGix6aa-jGwbhBVms2A2O01-s3_4c,27304
37
37
  plain/http/request.py,sha256=sqE83ZaB1P2i7iEUQ6d-K_6X4xhpdRdsPiTVraiDoNU,25984
38
- plain/http/response.py,sha256=QtJM4m8_imbYXSkwOAtMu9WCRZktvTsa4ZmVUAvz6bI,24250
38
+ plain/http/response.py,sha256=RR2sUG-ONWKWcZyIbztjWvtFyh0cR-CoxQvnWOyN0io,23619
39
39
  plain/internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
40
  plain/internal/files/README.md,sha256=kMux-NU5qiH0o1K8IajYQT8VjrYl_jLk9LkGG_kGuSc,45
41
41
  plain/internal/files/__init__.py,sha256=VctFgox4Q1AWF3klPaoCC5GIw5KeLafYjY5JmN8mAVw,63
@@ -49,9 +49,9 @@ plain/internal/files/utils.py,sha256=xN4HTJXDRdcoNyrL1dFd528MBwodRlHZM8DGTD_oBIg
49
49
  plain/internal/handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
50
  plain/internal/handlers/base.py,sha256=I6549DBZUb-anqox7arzL9wpypH4bUCxZkitO76hljI,4794
51
51
  plain/internal/handlers/exception.py,sha256=DH9gh1FyqgetFpMaB8yLIVE6phBTVPKQLA1GIn9MOeI,4555
52
- plain/internal/handlers/wsgi.py,sha256=EWoH9EeetfgiL0BtoAe2Aof0VWaBrxl74Y9EP4xx0wc,7553
52
+ plain/internal/handlers/wsgi.py,sha256=estA1QKHTk3ZqziWxenHsw5UO2cwPp3Zr0XjkDeM5TY,7561
53
53
  plain/internal/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
- plain/internal/middleware/headers.py,sha256=naYsFK0phMGFf1DlRj5fAYz78R5cXToCJfuqm0cR0nI,965
54
+ plain/internal/middleware/headers.py,sha256=ENIW1Gwat54hv-ejgp2R8QTZm-PlaI7k44WU01YQrNk,964
55
55
  plain/internal/middleware/https.py,sha256=XpuQK8HicYX1jNanQHqNgyQ9rqe4NLUOZO3ZzKdsP8k,1203
56
56
  plain/internal/middleware/slash.py,sha256=1rZsSSzXAA-vBb-dc2RlZaKW9gTT8YM8fJzwYGL4swA,2575
57
57
  plain/logs/README.md,sha256=H6uVXdInYlasq0Z1WnhWnPmNwYQoZ1MSLPDQ4ZE7u4A,492
@@ -90,7 +90,7 @@ plain/templates/jinja/filters.py,sha256=3KJKKbxcv9dLzUDWPcaa88k3NU2m1GG3iMIgFhzX
90
90
  plain/templates/jinja/globals.py,sha256=qhvQuikkRkOTpHSW5FwdsvoViJNlRgHq3-O7ZyeajsE,669
91
91
  plain/test/README.md,sha256=Zso3Ir7a8vQerzKB6egjROQWkpveLAbscn7VTROPAiU,37
92
92
  plain/test/__init__.py,sha256=rXe88Y602NP8DBnReSyXb7dUzKoWweLuT43j-qwOUl4,138
93
- plain/test/client.py,sha256=MYAvM1HOSfEktNEOSb9662qkhHfvnxYlY00Ckj3dL3I,31349
93
+ plain/test/client.py,sha256=Z9PQHLY-dg303P0bXJFIpmJuCjyB6oaD4opvla4yh-Q,31365
94
94
  plain/urls/README.md,sha256=pWnCvgYkWN7rG7hSyBOtX4ZUP3iO7FhqM6lvwwYll6c,33
95
95
  plain/urls/__init__.py,sha256=3UzwIufXjIks2K_X_Vms2MV19IqvyPLrXUeHU3WP47c,753
96
96
  plain/urls/base.py,sha256=Q1TzI5WvqYkN1U81fDom1q-AID4dXbszEMF6wAeTAI0,3717
@@ -101,7 +101,7 @@ plain/urls/resolvers.py,sha256=Fb2F1cdTxKDn0ZvNX81zHBglZs_aKMgnFuSIJVxNiUk,27508
101
101
  plain/utils/README.md,sha256=Bf5OG-MkOJDz_U8RGVreDfAI4M4nnPaLtk-LdinxHSc,99
102
102
  plain/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
103
103
  plain/utils/_os.py,sha256=oqfiKZRbmHwwWSZP36SIajQnFDbImbB6gcyK0idAGl4,1988
104
- plain/utils/cache.py,sha256=SM0jXxWU3XbaMPkthCsYWDYdZH5eOgGzKUgxV1ISNyE,11476
104
+ plain/utils/cache.py,sha256=3GtF8EU07LmD7CSvWSuF7YTThgeNxVkuU68wBK_35Wk,11489
105
105
  plain/utils/connection.py,sha256=NN7xRhy6qIWuOOhi1x9YdGcFcYhKepTiMUETeEMS0vY,2501
106
106
  plain/utils/crypto.py,sha256=zFDydnaqNMGYFHUc-CAn8f93685a17BhGusAcITH1lI,2662
107
107
  plain/utils/datastructures.py,sha256=g4UYTbxIb_n8F9JWMP4dHPwUz71591fHreGATPO4qEc,10240
@@ -138,8 +138,8 @@ plain/views/forms.py,sha256=RhlaUcZCkeqokY_fvv-NOS-kgZAG4XhDLOPbf9K_Zlc,2691
138
138
  plain/views/objects.py,sha256=fRfS6KNehIGqkbPw4nSafj8HStxYExHmbggolBbzcxs,7921
139
139
  plain/views/redirect.py,sha256=KLnlktzK6ZNMTlaEiZpMKQMEP5zeTgGLJ9BIkIJfwBo,1733
140
140
  plain/views/templates.py,sha256=nF9CcdhhjAyp3LB0RrSYnBaHpHzMfPSw719RCdcXk7o,2007
141
- plain-0.16.1.dist-info/METADATA,sha256=GoCuu4bEkD-XaOiuI-fBcEhUpCYvl0Eb5iChNKN0AqA,2518
142
- plain-0.16.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
143
- plain-0.16.1.dist-info/entry_points.txt,sha256=DHHprvufgd7xypiBiqMANYRnpJ9xPPYhYbnPGwOkWqE,40
144
- plain-0.16.1.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
145
- plain-0.16.1.dist-info/RECORD,,
141
+ plain-0.17.0.dist-info/METADATA,sha256=97ESRcFn2YsQ3VM9sIv5rO7j489XgP70TNssLtu5c08,2518
142
+ plain-0.17.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
143
+ plain-0.17.0.dist-info/entry_points.txt,sha256=DHHprvufgd7xypiBiqMANYRnpJ9xPPYhYbnPGwOkWqE,40
144
+ plain-0.17.0.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
145
+ plain-0.17.0.dist-info/RECORD,,
File without changes