cubicweb/server/test/data/hooks.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 10 Mar 2017 14:07:15 +0100
changeset 12031 92da3e6cb104
parent 12027 c62c80f20a82
child 12036 4c2c731f9190
permissions -rw-r--r--
[server] Fix flake8 error of test/data/hooks.py
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     1
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     3
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     4
# This file is part of CubicWeb.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     5
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     9
# any later version.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    10
#
5424
8ecbcbff9777 replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5421
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    14
# details.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    15
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    18
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    19
from cubicweb.server.hook import Hook
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    20
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    21
CALLED_EVENTS = {}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    22
12031
92da3e6cb104 [server] Fix flake8 error of test/data/hooks.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12027
diff changeset
    23
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    24
class StartupHook(Hook):
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    25
    __regid__ = 'mystartup'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    26
    events = ('server_startup',)
12031
92da3e6cb104 [server] Fix flake8 error of test/data/hooks.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12027
diff changeset
    27
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    28
    def __call__(self):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    29
        CALLED_EVENTS['server_startup'] = True
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    30
12031
92da3e6cb104 [server] Fix flake8 error of test/data/hooks.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12027
diff changeset
    31
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    32
class ShutdownHook(Hook):
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    33
    __regid__ = 'myshutdown'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    34
    events = ('server_shutdown',)
12031
92da3e6cb104 [server] Fix flake8 error of test/data/hooks.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12027
diff changeset
    35
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    36
    def __call__(self):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    37
        CALLED_EVENTS['server_shutdown'] = True
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    38
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    39
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    40
class LoginHook(Hook):
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    41
    __regid__ = 'mylogin'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    42
    events = ('session_open',)
12031
92da3e6cb104 [server] Fix flake8 error of test/data/hooks.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 12027
diff changeset
    43
3397
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    44
    def __call__(self):
a35c6ae5bef2 update hook api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    45
        CALLED_EVENTS['session_open'] = self._cw.user.login