# HG changeset patch # User Sylvain Thénault # Date 1269526107 -3600 # Node ID 72734c21083681aa7f19fe5c8318e8874b19a9f9 # Parent 2f2d9bc6dca46c1298f40b9289e41a824a3579c4 [c-c] new server_maintenance hook, called on c-c shell / upgrade diff -r 2f2d9bc6dca4 -r 72734c210836 server/hook.py --- a/server/hook.py Thu Mar 25 14:49:24 2010 +0100 +++ b/server/hook.py Thu Mar 25 15:08:27 2010 +0100 @@ -19,8 +19,11 @@ Relation (eg before_add_relation, after_add_relation, before_delete_relation, after_delete_relation) all have `eidfrom`, `rtype`, `eidto` attributes. -Server start/stop hooks (eg server_startup, server_shutdown) have a `repo` -attribute, but *their `_cw` attribute is None*. +Server start/maintenance/stop hooks (eg server_startup, server_maintenance, +server_shutdown) have a `repo` attribute, but *their `_cw` attribute is None*. +The `server_startup` is called on regular startup, while `server_maintenance` +is called on cubicweb-ctl upgrade or shell commands. `server_shutdown` is +called anyway. Backup/restore hooks (eg server_backup, server_restore) have a `repo` and a `timestamp` attributes, but *their `_cw` attribute is None*. @@ -57,7 +60,7 @@ 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_shutdown', + 'server_startup', 'server_maintenance', 'server_shutdown', 'session_open', 'session_close')) ALL_HOOKS = ENTITIES_HOOKS | RELATIONS_HOOKS | SYSTEM_HOOKS diff -r 2f2d9bc6dca4 -r 72734c210836 server/migractions.py --- a/server/migractions.py Thu Mar 25 14:49:24 2010 +0100 +++ b/server/migractions.py Thu Mar 25 15:08:27 2010 +0100 @@ -59,7 +59,6 @@ def __init__(self, config, schema, interactive=True, repo=None, cnx=None, verbosity=1, connect=True): MigrationHelper.__init__(self, config, interactive, verbosity) - # no config on shell to a remote instance if not interactive: assert cnx assert repo @@ -67,10 +66,12 @@ assert repo self._cnx = cnx self.repo = repo - if config is not None: - self.session.data['rebuild-infered'] = False elif connect: self.repo_connect() + # no config on shell to a remote instance + if config is not None: + self.session.data['rebuild-infered'] = False + self.repo.hm.call_hooks('server_maintenance', repo=self.repo) if not schema: schema = config.load_schema(expand_cubes=True) self.fs_schema = schema