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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce812e80ccef2658bd1dec1a3c53d595c0d96ca593ae75fd8df882429da5a8d4 |
|
MD5 | 32700f22fa031b92c8955c4230a437f6 |
|
BLAKE2b-256 | 817b03acd418e53441064f2c849427e48191d522f2aa0f34a2c822db75adb8e8 |
Close
Hashes for adsocket_transport_django-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7303097cbcf412eea9c288d47a11a6cc56976cb74aff6aafadd75a636320db1 |
|
MD5 | 431893258fb7966bfa2ad18ade1ec013 |
|
BLAKE2b-256 | 1c47e332b10a56ad2a2274e36d9f70c17840958a9cb4e370d78ff7dc298289dc |