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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc8d873dff4eee7e5fcdb842a79a6a7a46f2af2798556cb036dfd59d62737900 |
|
MD5 | 90bfbe0b2b5c780508048605f025eb01 |
|
BLAKE2b-256 | 6674e927dfdb197efbd491ceb49aa1f9dd2e86367950e8c62b1272b050bccf30 |
Close
Hashes for adsocket_transport_django-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6f969e727f2e352705e19ad272bf36556165cc8ac6d371478dd53f0356ba216 |
|
MD5 | 49af266e58db82b58bea487da97a3869 |
|
BLAKE2b-256 | f008947be38584f06803b335a374e8cf042cdfe3292294669be44156a99ca10b |