Skip to main content

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.

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.1.tar.gz (10.7 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.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for channels_extensions-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e5df0b3910468b41aab400e42627364d0553e7d5a5f97feba6c2cf31c38be921
MD5 3702860bad662e43d7157758f943c4ee
BLAKE2b-256 f138c98b8ce79233189156f3e4fd24f1326a50c22f9976215f3a229df61f92da

See more details on using hashes here.

Provenance

The following attestation bundles were made for channels_extensions-0.0.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for channels_extensions-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9408fad5aaf7c00eea1370c82bd2807f79b285231826e65551fe65c16efd34f2
MD5 9d6eeb78b3febaa79025b42feb09b047
BLAKE2b-256 30764b232e8ac18d91a381d517168bdfe3fc3e3e0bf19b641d1686df1d72e933

See more details on using hashes here.

Provenance

The following attestation bundles were made for channels_extensions-0.0.1-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.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page