Skip to main content

Webhooks for Django **EXPERIMENTAL**

Project description

Version:
0.0.1

Introduction

NOTE This software is just in the planning stage and is going to change drastically. You can follow what is happening here, and is welcome to help out making it happen, but you should probably not use it for anything until it has reached an alpha version.

>>> from django.db import signals
>>> from django.contrib.auth.models import User
>>> from durian.hook import ModelHook
>>> userhook = ModelHook(name="user-post-save",
...                      model=User,
...                      signal=signals.post_save,
...                      provides_args=["username", "is_admin"])
>>> # send event when Joe is changed
>>> userhook.listener(
...     url="http://where.joe/is/listening").match(
...     username="joe").save()
>>> # send event when any user is changed.
>>> userhook.listener(url="http://where.joe/is/listening").save()
>>> # Send event when Joe is admin
>>> userhook.listener(
...     url="http://where.joe/is/listening").match(
...         username="joe", is_admin=True).save()
>>> joe = User.objects.get(username="joe")
>>> joe.is_admin = True
>>> joe.save()

View for listening URL:

>>> from django.http import HttpResponse
>>> from anyjson import deserialize
>>> def listens(request):
...     payload = deserialize(request.raw_post_data)
...     print(payload["what"])
...     return HttpResponse("thanks!")

Installation

You can install durian either via the Python Package Index (PyPI) or from source.

To install using pip,:

$ pip install durian

To install using easy_install,:

$ easy_install durian

If you have downloaded a source tarball you can install it by doing the following,:

$ python setup.py build
# python setup.py install # as root

Examples

License

BSD License

Contact

Ask Solem <askh@opera.com>

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

durian-0.0.1.tar.gz (21.3 kB view hashes)

Uploaded Source

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