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.

Source Distribution

adsocket-transport-django-0.1.3.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file adsocket-transport-django-0.1.3.tar.gz.

File metadata

  • Download URL: adsocket-transport-django-0.1.3.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for adsocket-transport-django-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ce812e80ccef2658bd1dec1a3c53d595c0d96ca593ae75fd8df882429da5a8d4
MD5 32700f22fa031b92c8955c4230a437f6
BLAKE2b-256 817b03acd418e53441064f2c849427e48191d522f2aa0f34a2c822db75adb8e8

See more details on using hashes here.

File details

Details for the file adsocket_transport_django-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: adsocket_transport_django-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for adsocket_transport_django-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e7303097cbcf412eea9c288d47a11a6cc56976cb74aff6aafadd75a636320db1
MD5 431893258fb7966bfa2ad18ade1ec013
BLAKE2b-256 1c47e332b10a56ad2a2274e36d9f70c17840958a9cb4e370d78ff7dc298289dc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page