Skip to content

Commit 36da02e

Browse files
authored
v3.3.1 (#169)
1 parent 4fc2c8a commit 36da02e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+56
-55
lines changed

CHANGELOG.md

+12-1

docs/python/auth-required-attribute.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component, html
2-
32
from reactpy_django.decorators import auth_required
43

54

docs/python/auth-required-component-fallback.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component, html
2-
32
from reactpy_django.decorators import auth_required
43

54

docs/python/auth-required-custom-attribute.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component, html
2-
32
from reactpy_django.decorators import auth_required
43

54

docs/python/auth-required-vdom-fallback.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component, html
2-
32
from reactpy_django.decorators import auth_required
43

54

docs/python/auth-required.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component, html
2-
32
from reactpy_django.decorators import auth_required
43

54

docs/python/configure-asgi-middleware.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
# Broken load order, only used for linting
22
from channels.routing import ProtocolTypeRouter, URLRouter
3-
43
from reactpy_django import REACTPY_WEBSOCKET_PATH
54

6-
75
django_asgi_app = ""
86

97

108
# start
119
from channels.auth import AuthMiddlewareStack # noqa: E402
1210
from channels.sessions import SessionMiddlewareStack # noqa: E402
1311

14-
1512
application = ProtocolTypeRouter(
1613
{
1714
"http": django_asgi_app,

docs/python/configure-asgi.py

-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from django.core.asgi import get_asgi_application
44

5-
65
# Ensure DJANGO_SETTINGS_MODULE is set properly based on your project name!
76
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example_project.settings")
87

@@ -11,10 +10,8 @@
1110

1211

1312
from channels.routing import ProtocolTypeRouter, URLRouter # noqa: E402
14-
1513
from reactpy_django import REACTPY_WEBSOCKET_PATH # noqa: E402
1614

17-
1815
application = ProtocolTypeRouter(
1916
{
2017
"http": django_asgi_app,

docs/python/configure-urls.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from django.urls import include, path
22

3-
43
urlpatterns = [
54
...,
65
path("reactpy/", include("reactpy_django.http.urls")),

docs/python/django-css.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component, html
2-
32
from reactpy_django.components import django_css
43

54

docs/python/django-js.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component, html
2-
32
from reactpy_django.components import django_js
43

54

docs/python/django-query-postprocessor.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from example.models import TodoItem
22
from reactpy import component
3-
43
from reactpy_django.hooks import use_query
54
from reactpy_django.types import QueryOptions
65
from reactpy_django.utils import django_query_postprocessor

docs/python/example/urls.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from django.urls import path
22
from example import views
33

4-
54
urlpatterns = [
65
path("example/", views.index),
76
]

docs/python/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929

3030
# Whether to enable rendering ReactPy via a dedicated backhaul thread
3131
# This allows the webserver to process traffic while during ReactPy rendering
32-
REACTPY_BACKHAUL_THREAD = True
32+
REACTPY_BACKHAUL_THREAD = False

docs/python/use-connection.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component, html
2-
32
from reactpy_django.hooks import use_connection
43

54

docs/python/use-location.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component, html
2-
32
from reactpy_django.hooks import use_location
43

54

docs/python/use-mutation-args-kwargs.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component
2-
32
from reactpy_django.hooks import use_mutation
43

54

docs/python/use-mutation-query-refetch.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from example.models import TodoItem
22
from reactpy import component, html
3-
43
from reactpy_django.hooks import use_mutation, use_query
54

65

docs/python/use-mutation-reset.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from example.models import TodoItem
22
from reactpy import component, html
3-
43
from reactpy_django.hooks import use_mutation
54

65

docs/python/use-mutation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from example.models import TodoItem
22
from reactpy import component, html
3-
43
from reactpy_django.hooks import use_mutation
54

65

@@ -10,11 +9,12 @@ def add_item(text: str):
109

1110
@component
1211
def todo_list():
12+
item_mutation = use_mutation(add_item)
13+
1314
def submit_event(event):
1415
if event["key"] == "Enter":
1516
item_mutation.execute(text=event["target"]["value"])
1617

17-
item_mutation = use_mutation(add_item)
1818
if item_mutation.loading:
1919
mutation_status = html.h2("Adding...")
2020
elif item_mutation.error:

docs/python/use-origin.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component, html
2-
32
from reactpy_django.hooks import use_origin
43

54

docs/python/use-query-args.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component
2-
32
from reactpy_django.hooks import use_query
43

54

docs/python/use-query-async.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from channels.db import database_sync_to_async
22
from example.models import TodoItem
33
from reactpy import component, html
4-
54
from reactpy_django.hooks import use_query
65

76

docs/python/use-query-postprocessor-change.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component
2-
32
from reactpy_django.hooks import use_query
43
from reactpy_django.types import QueryOptions
54

docs/python/use-query-postprocessor-disable.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component
2-
32
from reactpy_django.hooks import use_query
43
from reactpy_django.types import QueryOptions
54

docs/python/use-query-postprocessor-kwargs.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from example.models import TodoItem
22
from reactpy import component
3-
43
from reactpy_django.hooks import use_query
54
from reactpy_django.types import QueryOptions
65

docs/python/use-query-thread-sensitive.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component
2-
32
from reactpy_django.hooks import use_query
43
from reactpy_django.types import QueryOptions
54

docs/python/use-query.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from example.models import TodoItem
22
from reactpy import component, html
3-
43
from reactpy_django.hooks import use_query
54

65

docs/python/use-scope.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from reactpy import component, html
2-
32
from reactpy_django.hooks import use_scope
43

54

docs/python/vtc-args-kwargs.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from django.http import HttpResponse
22
from reactpy import component, html
3-
43
from reactpy_django.components import view_to_component
54

65

docs/python/vtc-cbv-compatibility.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from django.contrib.auth.decorators import user_passes_test
22
from django.utils.decorators import method_decorator
33
from django.views.generic import TemplateView
4-
54
from reactpy_django.components import view_to_component
65

76

docs/python/vtc-cbv.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from django.http import HttpResponse
22
from django.views import View
33
from reactpy import component, html
4-
54
from reactpy_django.components import view_to_component
65

76

docs/python/vtc-compatibility.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from django.http import HttpResponse
22
from reactpy import component, html
3-
43
from reactpy_django.components import view_to_component
54

65

docs/python/vtc-fbv-compat.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from django.contrib.auth.decorators import user_passes_test
2-
32
from reactpy_django.components import view_to_component
43

54

docs/python/vtc-func.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from example.views import example_view
22
from reactpy import component, html
3-
43
from reactpy_django.components import view_to_component
54

6-
75
example_vtc = view_to_component(example_view)
86

97

docs/python/vtc-request.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from django.http import HttpRequest, HttpResponse
22
from reactpy import component, html
3-
43
from reactpy_django.components import view_to_component
54

6-
75
example_request = HttpRequest()
86
example_request.method = "PUT"
97

docs/python/vtc-strict-parsing.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from django.http import HttpResponse
22
from reactpy import component, html
3-
43
from reactpy_django.components import view_to_component
54

65

docs/python/vtc-transforms.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from django.http import HttpResponse
22
from reactpy import component, html
3-
43
from reactpy_django.components import view_to_component
54

65

docs/python/vtc.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from django.http import HttpResponse
22
from reactpy import component, html
3-
43
from reactpy_django.components import view_to_component
54

65

src/reactpy_django/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from reactpy_django import checks, components, decorators, hooks, types, utils
22
from reactpy_django.websocket.paths import REACTPY_WEBSOCKET_PATH
33

4-
__version__ = "3.3.0"
4+
__version__ = "3.3.1"
55
__all__ = [
66
"REACTPY_WEBSOCKET_PATH",
77
"hooks",

src/reactpy_django/checks.py

+39-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from django.contrib.staticfiles.finders import find
44
from django.core.checks import Error, Tags, Warning, register
5+
from django.template import loader
56

67

78
@register(Tags.compatibility)
@@ -48,7 +49,7 @@ def reactpy_warnings(app_configs, **kwargs):
4849
if (
4950
sys.argv
5051
and sys.argv[0].endswith("daphne")
51-
and getattr(settings, "REACTPY_BACKHAUL_THREAD", True)
52+
and getattr(settings, "REACTPY_BACKHAUL_THREAD", False)
5253
and sys.platform == "linux"
5354
):
5455
warnings.append(
@@ -76,11 +77,47 @@ def reactpy_warnings(app_configs, **kwargs):
7677
Warning(
7778
"ReactPy failed to register the following components:\n\t+ "
7879
+ "\n\t+ ".join(REACTPY_FAILED_COMPONENTS),
79-
hint="Check if these paths are valid, or if an exception is being raised during import.",
80+
hint="Check if these paths are valid, or if an exception is being "
81+
"raised during import.",
8082
id="reactpy_django.W005",
8183
)
8284
)
8385

86+
# Check if the reactpy/component.html template exists
87+
try:
88+
loader.get_template("reactpy/component.html")
89+
except Exception:
90+
warnings.append(
91+
Warning(
92+
"ReactPy HTML templates could not be found!",
93+
hint="Check your settings.py:TEMPLATES configuration and make sure "
94+
"ReactPy-Django is installed properly.",
95+
id="reactpy_django.W006",
96+
)
97+
)
98+
99+
# Check if REACTPY_WEBSOCKET_URL doesn't end with a slash
100+
REACTPY_WEBSOCKET_URL = getattr(settings, "REACTPY_WEBSOCKET_URL", "")
101+
if isinstance(REACTPY_WEBSOCKET_URL, str):
102+
if not REACTPY_WEBSOCKET_URL or not REACTPY_WEBSOCKET_URL.endswith("/"):
103+
warnings.append(
104+
Warning(
105+
"REACTPY_WEBSOCKET_URL did not end with a forward slash.",
106+
hint="Change your URL to be written in the following format: 'example_url/'",
107+
id="reactpy_django.W007",
108+
)
109+
)
110+
111+
# Check if REACTPY_WEBSOCKET_URL doesn't start with an alphanumeric character
112+
if not REACTPY_WEBSOCKET_URL or not REACTPY_WEBSOCKET_URL[0].isalnum():
113+
warnings.append(
114+
Warning(
115+
"REACTPY_WEBSOCKET_URL did not start with an alphanumeric character.",
116+
hint="Change your URL to be written in the following format: 'example_url/'",
117+
id="reactpy_django.W008",
118+
)
119+
)
120+
84121
return warnings
85122

86123

0 commit comments

Comments
 (0)