Skip to main content

Some extensions for Django Channels.

Project description

channels-extensions

PyPI - Version PyPI - Python Version


Installation

pip install channels-extensions

Usage

DummyChannelLayer

DummyChannelLayer is an noop (almost) implementation of BaseChannelLayer. Messages sent to it are never available, and receive never returns.

All methods work as checkpoints to the event loop, yielding control back to it at least once.

CHANNEL_LAYERS = {
    "dummy": {
        "BACKEND": "channels_extensions.layers.DummyChannelLayer",
    }
}

get_channel_layer

This is simply a version of channels get_channel_layer, but it raises an ImproperlyConfigured if the alias does not exist.

CurrentSiteMiddleware

A middleware that mimics django's CurrentSiteMiddleware. It adds a site key to the scope:

class EchoSiteConsumer(AsyncConsumer):
    async def websocket_connect(self, event):
        await self.send({
            "type": "websocket.accept",
        })

    async def websocket_receive(self, event):
        await self.send({
            "type": "websocket.send",
            "text": self.scope["site"],
        })

application = ProtocolTypeRouter({
    "websocket": AllowedHostsOriginValidator(
        AuthMiddlewareStack(
            CurrentSiteMiddleware(
                URLRouter([
                    path("echo/", EchoSiteConsumer.as_asgi()),
                ])
            )
        )
    ),
})

License

channels-extensions is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

channels_extensions-0.0.1a1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

channels_extensions-0.0.1a1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file channels_extensions-0.0.1a1.tar.gz.

File metadata

  • Download URL: channels_extensions-0.0.1a1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for channels_extensions-0.0.1a1.tar.gz
Algorithm Hash digest
SHA256 9980b763b420c9d1ef210b8426247d923fe8c5380989f2e7b28b7257831cc428
MD5 22f1e2614a98493f1e0b7747a6e738f6
BLAKE2b-256 56ba0a331d55514008b5b868e5d4ec3a272ac2ee405e0de0bc83ef2bdce8ff75

See more details on using hashes here.

Provenance

The following attestation bundles were made for channels_extensions-0.0.1a1.tar.gz:

Publisher: release.yml on hartungstenio/channels-extensions

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file channels_extensions-0.0.1a1-py3-none-any.whl.

File metadata

File hashes

Hashes for channels_extensions-0.0.1a1-py3-none-any.whl
Algorithm Hash digest
SHA256 d9eda9f64858000cfc636b21066aa8a110749a05f2ff77acdabc15cf20f22e95
MD5 ec5bc3ac30b5c2affce5293fe37b7b32
BLAKE2b-256 5406b8a6d5ce24cfbc68d3e3a363f7cf2c780e9ed36e8ecf3c3815b5bcf68aef

See more details on using hashes here.

Provenance

The following attestation bundles were made for channels_extensions-0.0.1a1-py3-none-any.whl:

Publisher: release.yml on hartungstenio/channels-extensions

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page