-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
108 lines (76 loc) · 2.56 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
Bambu Webhooks
==============
Create webhooks and allow users to assign URLs to them
About Bambu Webhooks
--------------------
This package allows web apps to provide third-party integration via
webhooks. You as the developer can trigger a webhook by name, and
provide an interface whereby the user can manage the URL to post the
webhook's data to.
About Bambu Tools 2.0
---------------------
This is part of a toolset called Bambu Tools. It's being moved from a
namespace of ``bambu`` to its own 'root-level' package, along with all
the other tools in the set. If you're upgrading from a version prior to
2.0, please make sure to update your code to use ``bambu_webhooks``
rather than ``bambu.webhooks``.
Installation
------------
Install the package via Pip:
::
pip install bambu-webhooks
Add it to your ``INSTALLED_APPS`` list:
::
INSTALLED_APPS = (
...
'bambu_webhooks'
)
Add ``bambu_webhooks.urls`` to your URLconf:
::
urlpatterns = patterns('',
...
url(r'^webhooks/', include('bambu_webhooks.urls')),
)
Run ``manage.py syncdb`` or ``manage.py migrate`` to setup the database
tables.
Basic usage
-----------
Register a webhook within your models.py file.
::
from hashlib import md5
import bambu_webhooks
bambu_webhooks.site.register('webhook_name_',
description = 'A description of the webhook'
)
In the ``save()`` method for your model, trigger any webhooks that have
receivers attached, thus posting the data to the user's specified URL.
::
def save(self, *args, **kwargs):
...
bambu_webhooks.send('webhook_name_', self.author,
{
'id': self.pk,
'name': self.name
},
md5('testproject.myapp.mymodel:%d' % self.pk).hexdigest()
)
Better with Bootstrap
---------------------
This package, among most in the Bambu toolset is designed to work with
`Bambu Bootstrap <https://github.com/iamsteadman/bambu-bootstrap>`_, a
collection of flexible templates designed for web apps based on the
Twitter Bootstrap framework. It's not a package requirement, but it'll
mean the template structure and the context variables exposed by the
view makes a little more sense.
Todo
----
- Allow webhooks to be categorised and/or filtered
- Prepare for internationalisation
- Write tests
Documentation
-------------
Full documentation can be found at
`ReadTheDocs <http://bambu-webhooks.readthedocs.org/>`_.
Questions or suggestions?
-------------------------
Find me on Twitter (@iamsteadman) or `visit my blog <http://steadman.io/>`_.