doc/book/devrepo/repo/notifications.rst
author Julien Cristau <julien.cristau@logilab.fr>
Wed, 17 Feb 2016 14:01:35 +0100
changeset 11246 ceb0e8e9129e
parent 10491 c67bcee93248
permissions -rw-r--r--
[migration] add rollback when replace_eid_sequence_with_eid_numrange fails If we get here, the current transaction is aborted, so if we are to assume everything is fine and continue we need to rollback first.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     1
.. -*- coding: utf-8 -*-
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     2
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     3
Notifications management
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     4
========================
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     5
8928
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
     6
CubicWeb provides a machinery to ease notifications handling. To use it for a
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
     7
notification:
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
     8
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
     9
* write a view inheriting from
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    10
  :class:`~cubicweb.sobjects.notification.NotificationView`.  The usual view api
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    11
  is used to generated the email (plain text) content, and additional
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    12
  :meth:`~cubicweb.sobjects.notification.NotificationView.subject` and
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    13
  :meth:`~cubicweb.sobjects.notification.NotificationView.recipients` methods
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    14
  are used to build the email's subject and
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    15
  recipients. :class:`NotificationView` provides default implementation for both
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    16
  methods.
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    17
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    18
* write a hook for event that should trigger this notification, select the view
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    19
  (without rendering it), and give it to
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    20
  :func:`cubicweb.hooks.notification.notify_on_commit` so that the notification
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    21
  will be sent if the transaction succeed.
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    22
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    23
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    24
.. XXX explain recipient finder and provide example
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    25
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    26
API details
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    27
~~~~~~~~~~~
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    28
.. autoclass:: cubicweb.sobjects.notification.NotificationView
f5b40b66d36e [notification] introduce an official `notify_on_commit` function
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5394
diff changeset
    29
.. autofunction:: cubicweb.hooks.notification.notify_on_commit