ADSocket transport library with Django integration
Project description
Adsocket transport
Install
pip install adsocket-transport-django
Usage
Using django.db.singals is very easy...
from django.apps import AppConfig
from adsocket_transport_django.apps import ADSocketConfig
class VideosConfig(ADSocketConfig, AppConfig):
"""
Basic application config
"""
name = "myapp"
verbose_name = "My App"
adsocket_signals = [
'myapp.ws_message_creator.VideoMessageCreator'
]
from adsocket_transport_django.creator import ADSocketCreator
from adsocket_transport_django import CREATE, UPDATE, DELETE, Message
from myapp import models
class VideoMessageCreator(ADSocketCreator):
class Meta:
model = models.Todo
def create(self, model):
return Message(
type='publish',
channel=f'todos:{model.pk}',
data={'obj': model.pk, 'action': 'create'}
)
def update(self, model):
return Message(
type='publish',
channel=f'todos:{model.pk}',
data={'obj': model.pk, 'action': 'update'}
)
def delete(self, model):
return Message(
type='publish',
channel=f'todos:{model.pk}',
data={'obj': model.pk, 'action': 'delete'}
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for adsocket-transport-django-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62317f2d5665cdb296777123c375fc1b9574cb3d0a12f5a524be9181810b824b |
|
MD5 | 3b16b0ececb0df32c255127dd320347a |
|
BLAKE2b-256 | 04027434f9240d1c84942ef92083355cd82ab9f0343b3dc29a6ba3da3a3f6b61 |
Close
Hashes for adsocket_transport_django-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42ce11da216e798363793aecddedd7b1a07cf303fa6e115096e46dc2817715a0 |
|
MD5 | c73d8a91f09575c108cdbf1d6cab4790 |
|
BLAKE2b-256 | 46a0517e0fc323fbbd8b0c609554cf62128d290c99d253be7bc551ee9fa226e5 |