{ "info": { "author": "Adam Jacquier-Parr", "author_email": "aljparr0@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "[![PyPI version](https://badge.fury.io/py/drf-model-pusher.svg)](https://badge.fury.io/py/drf-model-pusher)\n[![Build Status](https://travis-ci.org/aljp/drf_model_pusher.svg?branch=master)](https://travis-ci.org/aljp/drf_model_pusher)\n\n# DRF Model Pusher\n\nEasy to use class mixins for [Django Rest Framework]() and [Pusher]() to keep your API realtime.\n\n## Installation\n\nDownload from PyPI:\n\n`pip install drf_model_pusher`\n\n## Configuration\n\n### Settings Config\n\nIn your settings set your Pusher App Id and credentials, the cluster is optional\n\n```python\nPUSHER_APP_ID=\"\" \nPUSHER_KEY=\"\" \nPUSHER_SECRET=\"\"\nPUSHER_CLUSTER=\"\" \n```\n\n### Update Installed Apps\n\nAdd drf_model_pusher to your `INSTALLED_APPS`:\n\n```python\n\nINSTALLED_APPS = [\n \"...\",\n \"drf_model_pusher\",\n]\n``` \n\n### Implement Pusher Backends\n\nDefine some [PusherBackends]() for your models and serializers in a `pusher_backends.py` file. The PusherBackend class just needs to define a `serializer_class` attribute which inherits from `ModelSerializer`.\n\n```python\n# example/pusher_backends.py\n\nfrom django.db.models import Model\nfrom rest_framework.serializers import ModelSerializer\nfrom drf_model_pusher.backends import PusherBackend, PrivatePusherBackend\n\nclass MyModel(Model):\n pass\n\nclass MyModelSerializer(ModelSerializer):\n class Meta:\n model = MyModel\n\nclass MyModelPrivateSerializer(ModelSerializer):\n class Meta:\n model = MyModel\n\nclass MyModelPusherBackend(PusherBackend):\n serializer_class = MyModelSerializer\n \nclass MyModelPrivatePusherBackend(PrivatePusherBackend):\n serializer_class = MyModelPrivateSerializer\n```\n\n### Implement Views\n\nAdd the [ModelPusherViewMixin]() mixin class to your views and define a `get_pusher_channels` method which should return a list of strings to use as channels.\n\n```python\n# example/views.py\n\nfrom rest_framework.viewsets import ModelViewSet\nfrom drf_model_pusher.views import ModelPusherViewMixin\nfrom example.serializers import MyModelSerializer\n\nclass MyModelViewSet(ModelPusherViewMixin, ModelViewSet):\n serializer_class = MyModelSerializer\n \n def get_pusher_channels(self):\n return [\"\"]\n```\n\n### Ignoring the current connection\n\nIf you want to ignore the current connection when sending messages you should set a `x-pusher-socket-id` header on your requests. This may be useful if you're modifying resources and receiving the results in a response, you may not want the current connection to listen on these events to prevent duplicating content.\n\nThe PusherBackend.push_change method accepts an `ignore` boolean keyword argument which can toggle whether the pusher socket id is used, it defaults to `True`, so including the pusher socket id in the request will ignore the current connection for all pusher events sent by default.\n\n### Settings\n\n- `DRF_MODEL_PUSHER_BACKENDS_FILE` (default: `pusher_backends.py`) - The file in your applications to import PusherBackends.\n- `DRF_MODEL_PUSHER_DISABLED` (default: `False`) - Determines whether or not to trigger Pusher events.\n\n## Common Issues\n### Unregistered Backends\nIf you have followed the above steps correctly and your backends are not registering, your app config may not be running it's `ready` method. To force this, in your apps `__init__.py` add the line `default_app_config = 'myapp.apps.MyAppConfig'`\n\n### Pusher\nBe aware of any pusher limits and consult their documentation at [https://pusher.com/docs](https://pusher.com/docs) for some common questions. \n\n[Pusher has a 10kb default size limit on messages, this can be increased to 256kb by contacting support.](https://support.pusher.com/hc/en-us/articles/202046553-What-is-the-message-size-limit-when-publishing-a-message-)\n\n### Extending `PusherBackend`\nIf you want to extend `PusherBackend` or `PrivatePusherBackend` rather than declaring a new concrete backend, you need to make sure the class is abstract. For example your new base class would be similar to this:\n\n```python\nclass MyPusherBackend(PusherBackend):\n class Meta:\n abstract = True\n\n # Override whatever methods here\n\n\nclass MyModelBackend(MyPusherBackend):\n class Meta:\n model = MyModel\n```\n\n## Contributions\n\nIt's early days, but if you'd like to report any issues or work on an improvement then please check for any similar existing issues before you report them.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/aljp/drf_model_pusher", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "drf-model-pusher", "package_url": "https://pypi.org/project/drf-model-pusher/", "platform": "", "project_url": "https://pypi.org/project/drf-model-pusher/", "project_urls": { "Homepage": "https://github.com/aljp/drf_model_pusher" }, "release_url": "https://pypi.org/project/drf-model-pusher/0.2.0/", "requires_dist": null, "requires_python": ">=3.6.0", "summary": "Easy to use class mixins for Django Rest Framework and Pusher to keep your API realtime.", "version": "0.2.0" }, "last_serial": 4209734, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "da148fcd3901c46c426aba77d73ed629", "sha256": "9e7f64cf74da1708c900b4ffbf35cdd002a092ca98b2edcee36310c5bb8ca6c2" }, "downloads": -1, "filename": "drf_model_pusher-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "da148fcd3901c46c426aba77d73ed629", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 5877, "upload_time": "2018-07-22T22:58:16", "url": "https://files.pythonhosted.org/packages/e6/96/3c9562a25ad2d2b99370359377f3dfe9c21f9642faedd695296e5accce12/drf_model_pusher-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8e4fa3fea9057d075223d2f1637385ca", "sha256": "52d4d332a99e61da402a6d5831bf54dc78dbfb49db3513e5ee0419fdccf04427" }, "downloads": -1, "filename": "drf_model_pusher-0.1.0.tar.gz", "has_sig": false, "md5_digest": "8e4fa3fea9057d075223d2f1637385ca", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 5697, "upload_time": "2018-07-22T22:58:18", "url": "https://files.pythonhosted.org/packages/8e/e3/7457bd921cab396bd24b149b68d2e1f786a68b5ac89194ea26d54d7d243a/drf_model_pusher-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "26320c6f601d0766379be2af64e4fd84", "sha256": "f6439e19ba9bca365da8058588ed7abf6a78d54b5161ac30b7645a9bfbae7024" }, "downloads": -1, "filename": "drf_model_pusher-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "26320c6f601d0766379be2af64e4fd84", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 6325, "upload_time": "2018-07-25T23:09:13", "url": "https://files.pythonhosted.org/packages/18/0f/91c36387ce95b8c6ede920988a9dfe43691110f8a77147350b449f3f5623/drf_model_pusher-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c92c48a298c249aff240e0489a39b5f9", "sha256": "3839f3fa798055e60c2f1b66362eca15e1bedb75089e875d2c9ddbf284f4e3b8" }, "downloads": -1, "filename": "drf_model_pusher-0.1.1.tar.gz", "has_sig": false, "md5_digest": "c92c48a298c249aff240e0489a39b5f9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 5914, "upload_time": "2018-07-25T23:09:15", "url": "https://files.pythonhosted.org/packages/b7/8e/dd83c41b340c5d47c480ed628cc3438558af498c6f1914b45bec2760a96d/drf_model_pusher-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "52898847a6d07c503444d6433d0ef796", "sha256": "9eb4142f4c68d090ee96e103ae45b856aac2116c0208b621f3fcabc473bc18b1" }, "downloads": -1, "filename": "drf_model_pusher-0.2.0.tar.gz", "has_sig": false, "md5_digest": "52898847a6d07c503444d6433d0ef796", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 7098, "upload_time": "2018-08-27T03:43:14", "url": "https://files.pythonhosted.org/packages/4d/14/6671e7e3dfedc2c378f36b63238508ed0ad5fe72f8aa6dbb9be8d83eeba0/drf_model_pusher-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "52898847a6d07c503444d6433d0ef796", "sha256": "9eb4142f4c68d090ee96e103ae45b856aac2116c0208b621f3fcabc473bc18b1" }, "downloads": -1, "filename": "drf_model_pusher-0.2.0.tar.gz", "has_sig": false, "md5_digest": "52898847a6d07c503444d6433d0ef796", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 7098, "upload_time": "2018-08-27T03:43:14", "url": "https://files.pythonhosted.org/packages/4d/14/6671e7e3dfedc2c378f36b63238508ed0ad5fe72f8aa6dbb9be8d83eeba0/drf_model_pusher-0.2.0.tar.gz" } ] }