Skip to main content

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


Download files

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

Files for adsocket-transport-django, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size adsocket_transport_django-0.1.3-py3-none-any.whl (9.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size adsocket-transport-django-0.1.3.tar.gz (2.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page