{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-services/cliquet/pulls/comments/43725516","id":43725516,"diff_hunk":"@@ -3,30 +3,64 @@\n Notifications\n #############\n \n-Knowing when a bucket or a collection has been modified is very\n+Knowing collection has been modified is very\n useful to integrate a Cliquet-based application with other services.\n \n For example, a search service that gets notified everytime something\n has changed, can continuously update its indexes.\n \n Cliquet leverages Pyramid's built-in event system and produces\n-a :class:`cliquet.events.ResourceChanged` event everytime a resource has\n-been modified. Event listeners can then pick up those events and act upon them.\n+a :class:`cliquet.events.ResourceChanged` event everytime a record in a\n+:ref:`resource` has been modified.\n \n-The :class:`cliquet.events.ResourceChanged` event contains a payload with\n+Event listeners can then pick up those events and act upon them.\n+\n+.. code-block:: python\n+\n+    from cliquet.events import ResourceChanged\n+\n+\n+    def on_resource_changed(event):\n+        resource_name = event.payload['resource_name']\n+        action = event.payload['action']\n+\n+        if resource_name == 'user' and action == 'create':\n+            send_welcome_email(event.payload['user_id'])\n+\n+    config.add_subscriber(on_resource_changed, ResourceChanged)\n+\n+\n+The :class:`cliquet.events.ResourceChanged` event contains a ``payload`` attribute with\n the following information:\n \n - **timestamp**: the time of the event\n - **action**: what happened. 'create', 'update' or 'delete'\n - **uri**: the uri of the impacted resource\n - **user_id**: the authenticated user id\n-- **resource_name**: the name of the impacted resouce. 'bucket', 'collection'\n-  or 'record'\n-- **<resource_name>_id**: id of the impacted resouce\n+- **resource_name**: the name of the impacted resouce (e.g. 'mushroom', 'bucket',\n+  etc.)\n+- **<resource_name>_id**: id of the impacted record\n+- **<match-dict value>**: every matchdict values of the URL pattern\n+\n+\n+Event listeners\n+---------------\n+\n+It is possible for an application or a plugin to listen to the events and execute\n+some code. In this case, the notifications are synchronous.","path":"cliquet_docs/reference/notifications.rst","position":55,"original_position":55,"commit_id":"4af3b94d35463b2b74c4fc91b0b1de22cee50c87","original_commit_id":"4af3b94d35463b2b74c4fc91b0b1de22cee50c87","user":{"login":"tarekziade","id":250019,"avatar_url":"https://avatars.githubusercontent.com/u/250019?v=3","gravatar_id":"","url":"https://api.github.com/users/tarekziade","html_url":"https://github.com/tarekziade","followers_url":"https://api.github.com/users/tarekziade/followers","following_url":"https://api.github.com/users/tarekziade/following{/other_user}","gists_url":"https://api.github.com/users/tarekziade/gists{/gist_id}","starred_url":"https://api.github.com/users/tarekziade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarekziade/subscriptions","organizations_url":"https://api.github.com/users/tarekziade/orgs","repos_url":"https://api.github.com/users/tarekziade/repos","events_url":"https://api.github.com/users/tarekziade/events{/privacy}","received_events_url":"https://api.github.com/users/tarekziade/received_events","type":"User","site_admin":false},"body":"> In this case, the notifications are synchronous.\r\n\r\nWhy \"In this case\" - it's always the case, so I would change this sentence explaining that events are synchronously called when a request is handled\r\n","created_at":"2015-11-03T08:48:58Z","updated_at":"2015-11-03T08:48:58Z","html_url":"https://github.com/mozilla-services/cliquet/pull/534#discussion_r43725516","pull_request_url":"https://api.github.com/repos/mozilla-services/cliquet/pulls/534","_links":{"self":{"href":"https://api.github.com/repos/mozilla-services/cliquet/pulls/comments/43725516"},"html":{"href":"https://github.com/mozilla-services/cliquet/pull/534#discussion_r43725516"},"pull_request":{"href":"https://api.github.com/repos/mozilla-services/cliquet/pulls/534"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla-services/cliquet/pulls/534","id":49431400,"html_url":"https://github.com/mozilla-services/cliquet/pull/534","diff_url":"https://github.com/mozilla-services/cliquet/pull/534.diff","patch_url":"https://github.com/mozilla-services/cliquet/pull/534.patch","issue_url":"https://api.github.com/repos/mozilla-services/cliquet/issues/534","number":534,"state":"open","locked":false,"title":"Fix events documentation (fixes #535)","user":{"login":"leplatrem","id":546692,"avatar_url":"https://avatars.githubusercontent.com/u/546692?v=3","gravatar_id":"","url":"https://api.github.com/users/leplatrem","html_url":"https://github.com/leplatrem","followers_url":"https://api.github.com/users/leplatrem/followers","following_url":"https://api.github.com/users/leplatrem/following{/other_user}","gists_url":"https://api.github.com/users/leplatrem/gists{/gist_id}","starred_url":"https://api.github.com/users/leplatrem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leplatrem/subscriptions","organizations_url":"https://api.github.com/users/leplatrem/orgs","repos_url":"https://api.github.com/users/leplatrem/repos","events_url":"https://api.github.com/users/leplatrem/events{/privacy}","received_events_url":"https://api.github.com/users/leplatrem/received_events","type":"User","site_admin":false},"body":"Fixed several glitches and format/phrasing inconsistencies\r\n\r\n@tarekziade r?","created_at":"2015-11-02T13:32:31Z","updated_at":"2015-11-03T08:48:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5f0312c77a86a395f2f29b9d60798606cbd194d8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-services/cliquet/pulls/534/commits","review_comments_url":"https://api.github.com/repos/mozilla-services/cliquet/pulls/534/comments","review_comment_url":"https://api.github.com/repos/mozilla-services/cliquet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla-services/cliquet/issues/534/comments","statuses_url":"https://api.github.com/repos/mozilla-services/cliquet/statuses/4af3b94d35463b2b74c4fc91b0b1de22cee50c87","head":{"label":"mozilla-services:events-docs","ref":"events-docs","sha":"4af3b94d35463b2b74c4fc91b0b1de22cee50c87","user":{"login":"mozilla-services","id":1066228,"avatar_url":"https://avatars.githubusercontent.com/u/1066228?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-services","html_url":"https://github.com/mozilla-services","followers_url":"https://api.github.com/users/mozilla-services/followers","following_url":"https://api.github.com/users/mozilla-services/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-services/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-services/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-services/subscriptions","organizations_url":"https://api.github.com/users/mozilla-services/orgs","repos_url":"https://api.github.com/users/mozilla-services/repos","events_url":"https://api.github.com/users/mozilla-services/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-services/received_events","type":"Organization","site_admin":false},"repo":{"id":30921526,"name":"cliquet","full_name":"mozilla-services/cliquet","owner":{"login":"mozilla-services","id":1066228,"avatar_url":"https://avatars.githubusercontent.com/u/1066228?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-services","html_url":"https://github.com/mozilla-services","followers_url":"https://api.github.com/users/mozilla-services/followers","following_url":"https://api.github.com/users/mozilla-services/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-services/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-services/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-services/subscriptions","organizations_url":"https://api.github.com/users/mozilla-services/orgs","repos_url":"https://api.github.com/users/mozilla-services/repos","events_url":"https://api.github.com/users/mozilla-services/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-services/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-services/cliquet","description":"micro services API toolkit","fork":false,"url":"https://api.github.com/repos/mozilla-services/cliquet","forks_url":"https://api.github.com/repos/mozilla-services/cliquet/forks","keys_url":"https://api.github.com/repos/mozilla-services/cliquet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-services/cliquet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-services/cliquet/teams","hooks_url":"https://api.github.com/repos/mozilla-services/cliquet/hooks","issue_events_url":"https://api.github.com/repos/mozilla-services/cliquet/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-services/cliquet/events","assignees_url":"https://api.github.com/repos/mozilla-services/cliquet/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-services/cliquet/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-services/cliquet/tags","blobs_url":"https://api.github.com/repos/mozilla-services/cliquet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-services/cliquet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-services/cliquet/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-services/cliquet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-services/cliquet/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-services/cliquet/languages","stargazers_url":"https://api.github.com/repos/mozilla-services/cliquet/stargazers","contributors_url":"https://api.github.com/repos/mozilla-services/cliquet/contributors","subscribers_url":"https://api.github.com/repos/mozilla-services/cliquet/subscribers","subscription_url":"https://api.github.com/repos/mozilla-services/cliquet/subscription","commits_url":"https://api.github.com/repos/mozilla-services/cliquet/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-services/cliquet/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-services/cliquet/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-services/cliquet/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-services/cliquet/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-services/cliquet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-services/cliquet/merges","archive_url":"https://api.github.com/repos/mozilla-services/cliquet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-services/cliquet/downloads","issues_url":"https://api.github.com/repos/mozilla-services/cliquet/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-services/cliquet/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-services/cliquet/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-services/cliquet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-services/cliquet/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-services/cliquet/releases{/id}","created_at":"2015-02-17T14:53:58Z","updated_at":"2015-10-19T14:53:50Z","pushed_at":"2015-11-02T23:35:52Z","git_url":"git://github.com/mozilla-services/cliquet.git","ssh_url":"git@github.com:mozilla-services/cliquet.git","clone_url":"https://github.com/mozilla-services/cliquet.git","svn_url":"https://github.com/mozilla-services/cliquet","homepage":"http://cliquet.readthedocs.org","size":10407,"stargazers_count":27,"watchers_count":27,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":13,"mirror_url":null,"open_issues_count":54,"forks":13,"open_issues":54,"watchers":27,"default_branch":"master"}},"base":{"label":"mozilla-services:master","ref":"master","sha":"3195fe3430af4a30ce1ed9ca09093b1f7a6e91e1","user":{"login":"mozilla-services","id":1066228,"avatar_url":"https://avatars.githubusercontent.com/u/1066228?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-services","html_url":"https://github.com/mozilla-services","followers_url":"https://api.github.com/users/mozilla-services/followers","following_url":"https://api.github.com/users/mozilla-services/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-services/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-services/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-services/subscriptions","organizations_url":"https://api.github.com/users/mozilla-services/orgs","repos_url":"https://api.github.com/users/mozilla-services/repos","events_url":"https://api.github.com/users/mozilla-services/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-services/received_events","type":"Organization","site_admin":false},"repo":{"id":30921526,"name":"cliquet","full_name":"mozilla-services/cliquet","owner":{"login":"mozilla-services","id":1066228,"avatar_url":"https://avatars.githubusercontent.com/u/1066228?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-services","html_url":"https://github.com/mozilla-services","followers_url":"https://api.github.com/users/mozilla-services/followers","following_url":"https://api.github.com/users/mozilla-services/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-services/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-services/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-services/subscriptions","organizations_url":"https://api.github.com/users/mozilla-services/orgs","repos_url":"https://api.github.com/users/mozilla-services/repos","events_url":"https://api.github.com/users/mozilla-services/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-services/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-services/cliquet","description":"micro services API toolkit","fork":false,"url":"https://api.github.com/repos/mozilla-services/cliquet","forks_url":"https://api.github.com/repos/mozilla-services/cliquet/forks","keys_url":"https://api.github.com/repos/mozilla-services/cliquet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-services/cliquet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-services/cliquet/teams","hooks_url":"https://api.github.com/repos/mozilla-services/cliquet/hooks","issue_events_url":"https://api.github.com/repos/mozilla-services/cliquet/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-services/cliquet/events","assignees_url":"https://api.github.com/repos/mozilla-services/cliquet/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-services/cliquet/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-services/cliquet/tags","blobs_url":"https://api.github.com/repos/mozilla-services/cliquet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-services/cliquet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-services/cliquet/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-services/cliquet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-services/cliquet/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-services/cliquet/languages","stargazers_url":"https://api.github.com/repos/mozilla-services/cliquet/stargazers","contributors_url":"https://api.github.com/repos/mozilla-services/cliquet/contributors","subscribers_url":"https://api.github.com/repos/mozilla-services/cliquet/subscribers","subscription_url":"https://api.github.com/repos/mozilla-services/cliquet/subscription","commits_url":"https://api.github.com/repos/mozilla-services/cliquet/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-services/cliquet/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-services/cliquet/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-services/cliquet/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-services/cliquet/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-services/cliquet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-services/cliquet/merges","archive_url":"https://api.github.com/repos/mozilla-services/cliquet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-services/cliquet/downloads","issues_url":"https://api.github.com/repos/mozilla-services/cliquet/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-services/cliquet/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-services/cliquet/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-services/cliquet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-services/cliquet/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-services/cliquet/releases{/id}","created_at":"2015-02-17T14:53:58Z","updated_at":"2015-10-19T14:53:50Z","pushed_at":"2015-11-02T23:35:52Z","git_url":"git://github.com/mozilla-services/cliquet.git","ssh_url":"git@github.com:mozilla-services/cliquet.git","clone_url":"https://github.com/mozilla-services/cliquet.git","svn_url":"https://github.com/mozilla-services/cliquet","homepage":"http://cliquet.readthedocs.org","size":10407,"stargazers_count":27,"watchers_count":27,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":13,"mirror_url":null,"open_issues_count":54,"forks":13,"open_issues":54,"watchers":27,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-services/cliquet/pulls/534"},"html":{"href":"https://github.com/mozilla-services/cliquet/pull/534"},"issue":{"href":"https://api.github.com/repos/mozilla-services/cliquet/issues/534"},"comments":{"href":"https://api.github.com/repos/mozilla-services/cliquet/issues/534/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-services/cliquet/pulls/534/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-services/cliquet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla-services/cliquet/pulls/534/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-services/cliquet/statuses/4af3b94d35463b2b74c4fc91b0b1de22cee50c87"}}}}