13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
14 # details. |
14 # details. |
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """ |
|
19 |
18 |
20 """ |
|
21 from cubicweb.server.hook import Hook |
19 from cubicweb.server.hook import Hook |
22 |
20 |
23 CALLED_EVENTS = {} |
21 CALLED_EVENTS = {} |
24 |
22 |
|
23 |
25 class StartupHook(Hook): |
24 class StartupHook(Hook): |
26 __regid__ = 'mystartup' |
25 __regid__ = 'mystartup' |
27 events = ('server_startup',) |
26 events = ('server_startup',) |
|
27 |
28 def __call__(self): |
28 def __call__(self): |
29 CALLED_EVENTS['server_startup'] = True |
29 CALLED_EVENTS['server_startup'] = True |
|
30 |
30 |
31 |
31 class ShutdownHook(Hook): |
32 class ShutdownHook(Hook): |
32 __regid__ = 'myshutdown' |
33 __regid__ = 'myshutdown' |
33 events = ('server_shutdown',) |
34 events = ('server_shutdown',) |
|
35 |
34 def __call__(self): |
36 def __call__(self): |
35 CALLED_EVENTS['server_shutdown'] = True |
37 CALLED_EVENTS['server_shutdown'] = True |
36 |
38 |
37 |
39 |
38 class LoginHook(Hook): |
40 class LoginHook(Hook): |
39 __regid__ = 'mylogin' |
41 __regid__ = 'mylogin' |
40 events = ('session_open',) |
42 events = ('session_open',) |
|
43 |
41 def __call__(self): |
44 def __call__(self): |
42 CALLED_EVENTS['session_open'] = self._cw.user.login |
45 CALLED_EVENTS['session_open'] = self._cw.user.login |