Skip to content

v3.3.1 #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ Using the following categories, list your changes in this order:

- Nothing (yet)!

## [3.3.1] - 2023-08-08

### Added

- Additional system checks for ReactPy misconfigurations.

### Changed

- `REACTPY_BACKHAUL_THREAD` now defaults to `False`.

## [3.3.0] - 2023-08-05

### Added
Expand Down Expand Up @@ -313,7 +323,8 @@ Using the following categories, list your changes in this order:

- Support for IDOM within the Django

[unreleased]: https://github.com/reactive-python/reactpy-django/compare/3.3.0...HEAD
[unreleased]: https://github.com/reactive-python/reactpy-django/compare/3.3.1...HEAD
[3.3.1]: https://github.com/reactive-python/reactpy-django/compare/3.3.0...3.3.1
[3.3.0]: https://github.com/reactive-python/reactpy-django/compare/3.2.1...3.3.0
[3.2.1]: https://github.com/reactive-python/reactpy-django/compare/3.2.0...3.2.1
[3.2.0]: https://github.com/reactive-python/reactpy-django/compare/3.1.0...3.2.0
Expand Down
1 change: 0 additions & 1 deletion docs/python/auth-required-attribute.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component, html

from reactpy_django.decorators import auth_required


Expand Down
1 change: 0 additions & 1 deletion docs/python/auth-required-component-fallback.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component, html

from reactpy_django.decorators import auth_required


Expand Down
1 change: 0 additions & 1 deletion docs/python/auth-required-custom-attribute.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component, html

from reactpy_django.decorators import auth_required


Expand Down
1 change: 0 additions & 1 deletion docs/python/auth-required-vdom-fallback.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component, html

from reactpy_django.decorators import auth_required


Expand Down
1 change: 0 additions & 1 deletion docs/python/auth-required.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component, html

from reactpy_django.decorators import auth_required


Expand Down
3 changes: 0 additions & 3 deletions docs/python/configure-asgi-middleware.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# Broken load order, only used for linting
from channels.routing import ProtocolTypeRouter, URLRouter

from reactpy_django import REACTPY_WEBSOCKET_PATH


django_asgi_app = ""


# start
from channels.auth import AuthMiddlewareStack # noqa: E402
from channels.sessions import SessionMiddlewareStack # noqa: E402


application = ProtocolTypeRouter(
{
"http": django_asgi_app,
Expand Down
3 changes: 0 additions & 3 deletions docs/python/configure-asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from django.core.asgi import get_asgi_application


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

Expand All @@ -11,10 +10,8 @@


from channels.routing import ProtocolTypeRouter, URLRouter # noqa: E402

from reactpy_django import REACTPY_WEBSOCKET_PATH # noqa: E402


application = ProtocolTypeRouter(
{
"http": django_asgi_app,
Expand Down
1 change: 0 additions & 1 deletion docs/python/configure-urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.urls import include, path


urlpatterns = [
...,
path("reactpy/", include("reactpy_django.http.urls")),
Expand Down
1 change: 0 additions & 1 deletion docs/python/django-css.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component, html

from reactpy_django.components import django_css


Expand Down
1 change: 0 additions & 1 deletion docs/python/django-js.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component, html

from reactpy_django.components import django_js


Expand Down
1 change: 0 additions & 1 deletion docs/python/django-query-postprocessor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from example.models import TodoItem
from reactpy import component

from reactpy_django.hooks import use_query
from reactpy_django.types import QueryOptions
from reactpy_django.utils import django_query_postprocessor
Expand Down
1 change: 0 additions & 1 deletion docs/python/example/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.urls import path
from example import views


urlpatterns = [
path("example/", views.index),
]
2 changes: 1 addition & 1 deletion docs/python/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@

# Whether to enable rendering ReactPy via a dedicated backhaul thread
# This allows the webserver to process traffic while during ReactPy rendering
REACTPY_BACKHAUL_THREAD = True
REACTPY_BACKHAUL_THREAD = False
1 change: 0 additions & 1 deletion docs/python/use-connection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component, html

from reactpy_django.hooks import use_connection


Expand Down
1 change: 0 additions & 1 deletion docs/python/use-location.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component, html

from reactpy_django.hooks import use_location


Expand Down
1 change: 0 additions & 1 deletion docs/python/use-mutation-args-kwargs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component

from reactpy_django.hooks import use_mutation


Expand Down
1 change: 0 additions & 1 deletion docs/python/use-mutation-query-refetch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from example.models import TodoItem
from reactpy import component, html

from reactpy_django.hooks import use_mutation, use_query


Expand Down
1 change: 0 additions & 1 deletion docs/python/use-mutation-reset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from example.models import TodoItem
from reactpy import component, html

from reactpy_django.hooks import use_mutation


Expand Down
4 changes: 2 additions & 2 deletions docs/python/use-mutation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from example.models import TodoItem
from reactpy import component, html

from reactpy_django.hooks import use_mutation


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

@component
def todo_list():
item_mutation = use_mutation(add_item)

def submit_event(event):
if event["key"] == "Enter":
item_mutation.execute(text=event["target"]["value"])

item_mutation = use_mutation(add_item)
if item_mutation.loading:
mutation_status = html.h2("Adding...")
elif item_mutation.error:
Expand Down
1 change: 0 additions & 1 deletion docs/python/use-origin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component, html

from reactpy_django.hooks import use_origin


Expand Down
1 change: 0 additions & 1 deletion docs/python/use-query-args.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component

from reactpy_django.hooks import use_query


Expand Down
1 change: 0 additions & 1 deletion docs/python/use-query-async.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from channels.db import database_sync_to_async
from example.models import TodoItem
from reactpy import component, html

from reactpy_django.hooks import use_query


Expand Down
1 change: 0 additions & 1 deletion docs/python/use-query-postprocessor-change.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component

from reactpy_django.hooks import use_query
from reactpy_django.types import QueryOptions

Expand Down
1 change: 0 additions & 1 deletion docs/python/use-query-postprocessor-disable.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component

from reactpy_django.hooks import use_query
from reactpy_django.types import QueryOptions

Expand Down
1 change: 0 additions & 1 deletion docs/python/use-query-postprocessor-kwargs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from example.models import TodoItem
from reactpy import component

from reactpy_django.hooks import use_query
from reactpy_django.types import QueryOptions

Expand Down
1 change: 0 additions & 1 deletion docs/python/use-query-thread-sensitive.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component

from reactpy_django.hooks import use_query
from reactpy_django.types import QueryOptions

Expand Down
1 change: 0 additions & 1 deletion docs/python/use-query.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from example.models import TodoItem
from reactpy import component, html

from reactpy_django.hooks import use_query


Expand Down
1 change: 0 additions & 1 deletion docs/python/use-scope.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from reactpy import component, html

from reactpy_django.hooks import use_scope


Expand Down
1 change: 0 additions & 1 deletion docs/python/vtc-args-kwargs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.http import HttpResponse
from reactpy import component, html

from reactpy_django.components import view_to_component


Expand Down
1 change: 0 additions & 1 deletion docs/python/vtc-cbv-compatibility.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.contrib.auth.decorators import user_passes_test
from django.utils.decorators import method_decorator
from django.views.generic import TemplateView

from reactpy_django.components import view_to_component


Expand Down
1 change: 0 additions & 1 deletion docs/python/vtc-cbv.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.http import HttpResponse
from django.views import View
from reactpy import component, html

from reactpy_django.components import view_to_component


Expand Down
1 change: 0 additions & 1 deletion docs/python/vtc-compatibility.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.http import HttpResponse
from reactpy import component, html

from reactpy_django.components import view_to_component


Expand Down
1 change: 0 additions & 1 deletion docs/python/vtc-fbv-compat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.contrib.auth.decorators import user_passes_test

from reactpy_django.components import view_to_component


Expand Down
2 changes: 0 additions & 2 deletions docs/python/vtc-func.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from example.views import example_view
from reactpy import component, html

from reactpy_django.components import view_to_component


example_vtc = view_to_component(example_view)


Expand Down
2 changes: 0 additions & 2 deletions docs/python/vtc-request.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from django.http import HttpRequest, HttpResponse
from reactpy import component, html

from reactpy_django.components import view_to_component


example_request = HttpRequest()
example_request.method = "PUT"

Expand Down
1 change: 0 additions & 1 deletion docs/python/vtc-strict-parsing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.http import HttpResponse
from reactpy import component, html

from reactpy_django.components import view_to_component


Expand Down
1 change: 0 additions & 1 deletion docs/python/vtc-transforms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.http import HttpResponse
from reactpy import component, html

from reactpy_django.components import view_to_component


Expand Down
1 change: 0 additions & 1 deletion docs/python/vtc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.http import HttpResponse
from reactpy import component, html

from reactpy_django.components import view_to_component


Expand Down
2 changes: 1 addition & 1 deletion src/reactpy_django/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from reactpy_django import checks, components, decorators, hooks, types, utils
from reactpy_django.websocket.paths import REACTPY_WEBSOCKET_PATH

__version__ = "3.3.0"
__version__ = "3.3.1"
__all__ = [
"REACTPY_WEBSOCKET_PATH",
"hooks",
Expand Down
41 changes: 39 additions & 2 deletions src/reactpy_django/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django.contrib.staticfiles.finders import find
from django.core.checks import Error, Tags, Warning, register
from django.template import loader


@register(Tags.compatibility)
Expand Down Expand Up @@ -48,7 +49,7 @@ def reactpy_warnings(app_configs, **kwargs):
if (
sys.argv
and sys.argv[0].endswith("daphne")
and getattr(settings, "REACTPY_BACKHAUL_THREAD", True)
and getattr(settings, "REACTPY_BACKHAUL_THREAD", False)
and sys.platform == "linux"
):
warnings.append(
Expand Down Expand Up @@ -76,11 +77,47 @@ def reactpy_warnings(app_configs, **kwargs):
Warning(
"ReactPy failed to register the following components:\n\t+ "
+ "\n\t+ ".join(REACTPY_FAILED_COMPONENTS),
hint="Check if these paths are valid, or if an exception is being raised during import.",
hint="Check if these paths are valid, or if an exception is being "
"raised during import.",
id="reactpy_django.W005",
)
)

# Check if the reactpy/component.html template exists
try:
loader.get_template("reactpy/component.html")
except Exception:
warnings.append(
Warning(
"ReactPy HTML templates could not be found!",
hint="Check your settings.py:TEMPLATES configuration and make sure "
"ReactPy-Django is installed properly.",
id="reactpy_django.W006",
)
)

# Check if REACTPY_WEBSOCKET_URL doesn't end with a slash
REACTPY_WEBSOCKET_URL = getattr(settings, "REACTPY_WEBSOCKET_URL", "")
if isinstance(REACTPY_WEBSOCKET_URL, str):
if not REACTPY_WEBSOCKET_URL or not REACTPY_WEBSOCKET_URL.endswith("/"):
warnings.append(
Warning(
"REACTPY_WEBSOCKET_URL did not end with a forward slash.",
hint="Change your URL to be written in the following format: 'example_url/'",
id="reactpy_django.W007",
)
)

# Check if REACTPY_WEBSOCKET_URL doesn't start with an alphanumeric character
if not REACTPY_WEBSOCKET_URL or not REACTPY_WEBSOCKET_URL[0].isalnum():
warnings.append(
Warning(
"REACTPY_WEBSOCKET_URL did not start with an alphanumeric character.",
hint="Change your URL to be written in the following format: 'example_url/'",
id="reactpy_django.W008",
)
)

return warnings


Expand Down
Loading