plain 0.34.1__py3-none-any.whl → 0.35.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/test/client.py CHANGED
@@ -17,7 +17,6 @@ from plain.urls import get_resolver
17
17
  from plain.utils.encoding import force_bytes
18
18
  from plain.utils.functional import SimpleLazyObject
19
19
  from plain.utils.http import urlencode
20
- from plain.utils.module_loading import import_string
21
20
  from plain.utils.regex_helper import _lazy_re_compile
22
21
 
23
22
  from .encoding import encode_multipart
@@ -776,11 +775,12 @@ class Client(RequestFactory):
776
775
  @property
777
776
  def session(self):
778
777
  """Return the current session variables."""
779
- Session = import_string(settings.SESSION_CLASS)
778
+ from plain.sessions import SessionStore
779
+
780
780
  cookie = self.cookies.get(settings.SESSION_COOKIE_NAME)
781
781
  if cookie:
782
- return Session(cookie.value)
783
- session = Session()
782
+ return SessionStore(cookie.value)
783
+ session = SessionStore()
784
784
  session.save()
785
785
  self.cookies[settings.SESSION_COOKIE_NAME] = session.session_key
786
786
  return session
@@ -790,14 +790,14 @@ class Client(RequestFactory):
790
790
 
791
791
  def _login(self, user):
792
792
  from plain.auth import login
793
+ from plain.sessions import SessionStore
793
794
 
794
795
  # Create a fake request to store login details.
795
796
  request = HttpRequest()
796
797
  if self.session:
797
798
  request.session = self.session
798
799
  else:
799
- Session = import_string(settings.SESSION_CLASS)
800
- request.session = Session()
800
+ request.session = SessionStore()
801
801
  login(request, user)
802
802
  # Save the session values.
803
803
  request.session.save()
@@ -816,14 +816,14 @@ class Client(RequestFactory):
816
816
  def logout(self):
817
817
  """Log out the user by removing the cookies and session object."""
818
818
  from plain.auth import get_user, logout
819
+ from plain.sessions import SessionStore
819
820
 
820
821
  request = HttpRequest()
821
822
  if self.session:
822
823
  request.session = self.session
823
824
  request.user = get_user(request)
824
825
  else:
825
- Session = import_string(settings.SESSION_CLASS)
826
- request.session = Session()
826
+ request.session = SessionStore()
827
827
  logout(request)
828
828
  self.cookies = SimpleCookie()
829
829
 
plain/views/base.py CHANGED
@@ -85,7 +85,8 @@ class View:
85
85
  return result
86
86
 
87
87
  if isinstance(result, str):
88
- return Response(result, content_type="text/plain")
88
+ # Assume the str is rendered HTML
89
+ return Response(result)
89
90
 
90
91
  if isinstance(result, list):
91
92
  return JsonResponse(result, safe=False)
plain/views/redirect.py CHANGED
@@ -20,6 +20,11 @@ class RedirectView(View):
20
20
  pattern_name: str | None = None
21
21
  query_string = False
22
22
 
23
+ def __init__(self, url=None, permanent=None):
24
+ # Allow url and permanent to be set in RedirectView.as_view(url="...", permanent=True)
25
+ self.url = url or self.url
26
+ self.permanent = permanent if permanent is not None else self.permanent
27
+
23
28
  def get_redirect_url(self):
24
29
  """
25
30
  Return the URL redirect to. Keyword arguments from the URL pattern
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain
3
- Version: 0.34.1
3
+ Version: 0.35.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
@@ -88,7 +88,7 @@ plain/templates/jinja/filters.py,sha256=3KJKKbxcv9dLzUDWPcaa88k3NU2m1GG3iMIgFhzX
88
88
  plain/templates/jinja/globals.py,sha256=VMpuMZvwWOmb5MbzKK-ox-QEX_WSsXFxq0mm8biJgaU,558
89
89
  plain/test/README.md,sha256=fv4YzziU2QxgcNHSgv7aDUO45sDOofVuCNrV1NPbWzo,1106
90
90
  plain/test/__init__.py,sha256=MhNHtp7MYBl9kq-pMRGY11kJ6kU1I6vOkjNkit1TYRg,94
91
- plain/test/client.py,sha256=kQiC-lu2x1p9Hvcs9_aa3DmOfLRaHIiarKtMmLmlJl4,26994
91
+ plain/test/client.py,sha256=lqzOf8EJo_u54dW_oiPy0m5mW-Nt3-CWyrBh9_MJnms,26930
92
92
  plain/test/encoding.py,sha256=YJBOIE-BQRA5yl4zHnQy-9l67mJDTFmfy1DQXK0Wk-Q,3199
93
93
  plain/test/exceptions.py,sha256=b-GHicg87Gh73W3g8QGWuSHi9PrQFVsxgWvEXDLt8gQ,290
94
94
  plain/urls/README.md,sha256=ijFGmrkUY9buBqO_i1GZaN3V55vl9xwEADtHOx_ZHPY,3724
@@ -126,16 +126,16 @@ plain/utils/timezone.py,sha256=6u0sE-9RVp0_OCe0Y1KiYYQoq5THWLokZFQYY8jf78g,6221
126
126
  plain/utils/tree.py,sha256=wdWzmfsgc26YDF2wxhAY3yVxXTixQYqYDKE9mL3L3ZY,4383
127
127
  plain/views/README.md,sha256=JyqAWMXYdaVnRncmb12yvlBhC629zRtWR7uzkKFwc9Y,5998
128
128
  plain/views/__init__.py,sha256=a-N1nkklVohJTtz0yD1MMaS0g66HviEjsKydNVVjvVc,392
129
- plain/views/base.py,sha256=6Q67PEioF7b0OHqrYCu56KUCHqJ-Gr4vefMwuAXt38w,3256
129
+ plain/views/base.py,sha256=E6TjfCJYbf7Jh2P-Zd2YsLJbC99Gj9bN21Y_CMqQAao,3275
130
130
  plain/views/csrf.py,sha256=7q6l5xzLWhRnMY64aNj0hR6G-3pxI2yhRwG6k_5j00E,144
131
131
  plain/views/errors.py,sha256=jbNCJIzowwCsEvqyJ3opMeZpPDqTyhtrbqb0VnAm2HE,1263
132
132
  plain/views/exceptions.py,sha256=b4euI49ZUKS9O8AGAcFfiDpstzkRAuuj_uYQXzWNHME,138
133
133
  plain/views/forms.py,sha256=5L6dYkwcZFMD3-w_QC2QDElo9hhSPrhVVFq9CB5yL9k,2692
134
134
  plain/views/objects.py,sha256=g5Lzno0Zsv0K449UpcCtxwCoO7WMRAWqKlxxV2V0_qg,8263
135
- plain/views/redirect.py,sha256=9zHZgKvtSkdrMX9KmsRM8hJTPmBktxhc4d8OitbuniI,1724
135
+ plain/views/redirect.py,sha256=vMXx8430FtyKcT0V0gyY92SkLtyULBX52KhX4eu4gEA,1985
136
136
  plain/views/templates.py,sha256=gwPqRki3SVcaTmtSCEp1MycUB-1saDYeYzmZZTQLxjE,2117
137
- plain-0.34.1.dist-info/METADATA,sha256=dLvkActYXqeXXsOPWzMPyteeRejGun_Zg77EY2UQRRI,3944
138
- plain-0.34.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
139
- plain-0.34.1.dist-info/entry_points.txt,sha256=1Ys2lsSeMepD1vz8RSrJopna0RQfUd951vYvCRsvl6A,45
140
- plain-0.34.1.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
141
- plain-0.34.1.dist-info/RECORD,,
137
+ plain-0.35.0.dist-info/METADATA,sha256=GAMRCUdN1HOOzB3UOXvHSKZ2q04mhjmFZK2eJJYLdWM,3944
138
+ plain-0.35.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
139
+ plain-0.35.0.dist-info/entry_points.txt,sha256=1Ys2lsSeMepD1vz8RSrJopna0RQfUd951vYvCRsvl6A,45
140
+ plain-0.35.0.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
141
+ plain-0.35.0.dist-info/RECORD,,
File without changes