[events] add a new before_shutdown event (closes #2345728)
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 09 May 2012 16:43:48 +0200
changeset 8393 77c7158916c1
parent 8392 c25b96ae4f8a
child 8394 b8b23af60019
[events] add a new before_shutdown event (closes #2345728)
server/hook.py
server/repository.py
--- a/server/hook.py	Wed May 09 16:35:46 2012 +0200
+++ b/server/hook.py	Wed May 09 16:43:48 2012 +0200
@@ -273,7 +273,8 @@
 RELATIONS_HOOKS = set(('before_add_relation',   'after_add_relation' ,
                        'before_delete_relation','after_delete_relation'))
 SYSTEM_HOOKS = set(('server_backup', 'server_restore',
-                    'server_startup', 'server_maintenance', 'server_shutdown',
+                    'server_startup', 'server_maintenance',
+                    'server_shutdown', 'before_server_shutdown',
                     'session_open', 'session_close'))
 ALL_HOOKS = ENTITIES_HOOKS | RELATIONS_HOOKS | SYSTEM_HOOKS
 
--- a/server/repository.py	Wed May 09 16:35:46 2012 +0200
+++ b/server/repository.py	Wed May 09 16:43:48 2012 +0200
@@ -425,6 +425,10 @@
         connections
         """
         assert not self.shutting_down, 'already shutting down'
+        if not (self.config.creating or self.config.repairing
+                or self.config.quick_start):
+            # then, the system source is still available
+            self.hm.call_hooks('before_server_shutdown', repo=self)
         self.shutting_down = True
         self.system_source.shutdown()
         if self._tasks_manager is not None: