doc/book/devrepo/repo/notifications.rst
changeset 10491 c67bcee93248
parent 8928 f5b40b66d36e
equal deleted inserted replaced
10490:76ab3c71aff2 10491:c67bcee93248
       
     1 .. -*- coding: utf-8 -*-
       
     2 
       
     3 Notifications management
       
     4 ========================
       
     5 
       
     6 CubicWeb provides a machinery to ease notifications handling. To use it for a
       
     7 notification:
       
     8 
       
     9 * write a view inheriting from
       
    10   :class:`~cubicweb.sobjects.notification.NotificationView`.  The usual view api
       
    11   is used to generated the email (plain text) content, and additional
       
    12   :meth:`~cubicweb.sobjects.notification.NotificationView.subject` and
       
    13   :meth:`~cubicweb.sobjects.notification.NotificationView.recipients` methods
       
    14   are used to build the email's subject and
       
    15   recipients. :class:`NotificationView` provides default implementation for both
       
    16   methods.
       
    17 
       
    18 * write a hook for event that should trigger this notification, select the view
       
    19   (without rendering it), and give it to
       
    20   :func:`cubicweb.hooks.notification.notify_on_commit` so that the notification
       
    21   will be sent if the transaction succeed.
       
    22 
       
    23 
       
    24 .. XXX explain recipient finder and provide example
       
    25 
       
    26 API details
       
    27 ~~~~~~~~~~~
       
    28 .. autoclass:: cubicweb.sobjects.notification.NotificationView
       
    29 .. autofunction:: cubicweb.hooks.notification.notify_on_commit