3 :organization: Logilab |
3 :organization: Logilab |
4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
7 """ |
7 """ |
8 from cubicweb.server.hooksmanager import SystemHook |
8 from cubicweb.server.hook import Hook |
9 |
9 |
10 CALLED_EVENTS = {} |
10 CALLED_EVENTS = {} |
11 |
11 |
12 class StartupHook(SystemHook): |
12 class StartupHook(Hook): |
|
13 __regid__ = 'mystartup' |
13 events = ('server_startup',) |
14 events = ('server_startup',) |
14 def call(self, repo): |
15 def __call__(self): |
15 CALLED_EVENTS['server_startup'] = True |
16 CALLED_EVENTS['server_startup'] = True |
16 |
17 |
17 class ShutdownHook(SystemHook): |
18 class ShutdownHook(Hook): |
|
19 __regid__ = 'myshutdown' |
18 events = ('server_shutdown',) |
20 events = ('server_shutdown',) |
19 def call(self, repo): |
21 def __call__(self): |
20 CALLED_EVENTS['server_shutdown'] = True |
22 CALLED_EVENTS['server_shutdown'] = True |
21 |
23 |
22 |
24 |
23 class LoginHook(SystemHook): |
25 class LoginHook(Hook): |
|
26 __regid__ = 'mylogin' |
24 events = ('session_open',) |
27 events = ('session_open',) |
25 def call(self, session): |
28 def __call__(self): |
26 CALLED_EVENTS['session_open'] = session.user.login |
29 CALLED_EVENTS['session_open'] = self._cw.user.login |
27 |
30 |
28 class LogoutHook(SystemHook): |
31 class LogoutHook(Hook): |
|
32 __regid__ = 'mylogout' |
29 events = ('session_close',) |
33 events = ('session_close',) |
30 def call(self, session): |
34 def __call__(self): |
31 CALLED_EVENTS['session_close'] = session.user.login |
35 CALLED_EVENTS['session_close'] = self._cw.user.login |