server/test/data/hooks.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 26 Jan 2010 13:38:02 +0100
changeset 4367 fa02f7dccfe4
parent 4252 6c4f109c2b03
child 5421 8167de96c523
permissions -rw-r--r--
fix deprecation warnings
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
     1
"""
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
     2
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
     3
:organization: Logilab
4212
ab6573088b4a update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
     4
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
     5
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
     6
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
     7
"""
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
     8
from cubicweb.server.hook import Hook
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     9
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    10
CALLED_EVENTS = {}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    11
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    12
class StartupHook(Hook):
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    13
    __regid__ = 'mystartup'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    14
    events = ('server_startup',)
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    15
    def __call__(self):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    16
        CALLED_EVENTS['server_startup'] = True
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    17
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    18
class ShutdownHook(Hook):
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    19
    __regid__ = 'myshutdown'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    20
    events = ('server_shutdown',)
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    21
    def __call__(self):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    22
        CALLED_EVENTS['server_shutdown'] = True
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    23
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    24
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    25
class LoginHook(Hook):
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    26
    __regid__ = 'mylogin'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    27
    events = ('session_open',)
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    28
    def __call__(self):
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    29
        CALLED_EVENTS['session_open'] = self._cw.user.login
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    30
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    31
class LogoutHook(Hook):
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    32
    __regid__ = 'mylogout'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    33
    events = ('session_close',)
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    34
    def __call__(self):
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    35
        CALLED_EVENTS['session_close'] = self._cw.user.login