server/migractions.py
branchstable
changeset 6205 41e0e13e10b7
parent 6203 d3dea5f84404
child 6208 07b176640a8c
equal deleted inserted replaced
6204:fd6d8f4d1904 6205:41e0e13e10b7
    71     __select__ = hook.Hook.__select__ & is_instance('CWGroup')
    71     __select__ = hook.Hook.__select__ & is_instance('CWGroup')
    72     events = ('after_add_entity', 'after_update_entity',)
    72     events = ('after_add_entity', 'after_update_entity',)
    73     def __call__(self):
    73     def __call__(self):
    74         clear_cache(self.mih, 'group_mapping')
    74         clear_cache(self.mih, 'group_mapping')
    75         self.mih._synchronized.clear()
    75         self.mih._synchronized.clear()
       
    76 
       
    77     @classmethod
       
    78     def mih_register(cls, repo):
       
    79         # may be already registered in tests (e.g. unittest_migractions at
       
    80         # least)
       
    81         if not cls.__regid__ in repo.vreg['after_add_entity_hooks']:
       
    82             repo.vreg.register(ClearGroupMap)
    76 
    83 
    77 class ServerMigrationHelper(MigrationHelper):
    84 class ServerMigrationHelper(MigrationHelper):
    78     """specific migration helper for server side  migration scripts,
    85     """specific migration helper for server side  migration scripts,
    79     providind actions related to schema/data migration
    86     providind actions related to schema/data migration
    80     """
    87     """
    96             repo = self.repo
   103             repo = self.repo
    97             self.session.data['rebuild-infered'] = False
   104             self.session.data['rebuild-infered'] = False
    98             # register a hook to clear our group_mapping cache and the
   105             # register a hook to clear our group_mapping cache and the
    99             # self._synchronized set when some group is added or updated
   106             # self._synchronized set when some group is added or updated
   100             ClearGroupMap.mih = self
   107             ClearGroupMap.mih = self
   101             # may be already registered in tests (e.g. unittest_migractions)
   108             ClearGroupMap.mih_register(repo)
   102             if not ClearGroupMap.__regid__ in repo.vreg['after_add_entity_hooks']:
   109             CW_EVENT_MANAGER.bind('after-registry-reload',
   103                 repo.vreg.register(ClearGroupMap)
   110                                   ClearGroupMap.mih_register, repo)
   104                 CW_EVENT_MANAGER.bind('after-registry-reload',
       
   105                                       repo.vreg.register, ClearGroupMap)
       
   106             # notify we're starting maintenance (called instead of server_start
   111             # notify we're starting maintenance (called instead of server_start
   107             # which is called on regular start
   112             # which is called on regular start
   108             repo.hm.call_hooks('server_maintenance', repo=repo)
   113             repo.hm.call_hooks('server_maintenance', repo=repo)
   109         if not schema and not getattr(config, 'quick_start', False):
   114         if not schema and not getattr(config, 'quick_start', False):
   110             schema = config.load_schema(expand_cubes=True)
   115             schema = config.load_schema(expand_cubes=True)