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.0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adsocket_transport_django-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: adsocket-transport-django-0.1.0.tar.gz
  • Upload date:
  • Size: 2.4 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.0.tar.gz
Algorithm Hash digest
SHA256 62317f2d5665cdb296777123c375fc1b9574cb3d0a12f5a524be9181810b824b
MD5 3b16b0ececb0df32c255127dd320347a
BLAKE2b-256 04027434f9240d1c84942ef92083355cd82ab9f0343b3dc29a6ba3da3a3f6b61

See more details on using hashes here.

File details

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

File metadata

  • Download URL: adsocket_transport_django-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 42ce11da216e798363793aecddedd7b1a07cf303fa6e115096e46dc2817715a0
MD5 c73d8a91f09575c108cdbf1d6cab4790
BLAKE2b-256 46a0517e0fc323fbbd8b0c609554cf62128d290c99d253be7bc551ee9fa226e5

See more details on using hashes here.

Supported by

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