hooks/syncsources.py
changeset 7399 972ed1843bd8
parent 7049 f2ae6202754c
child 7536 29961a416faa
equal deleted inserted replaced
7398:26695dd703d8 7399:972ed1843bd8
    27 
    27 
    28 class SourceHook(hook.Hook):
    28 class SourceHook(hook.Hook):
    29     __abstract__ = True
    29     __abstract__ = True
    30     category = 'cw.sources'
    30     category = 'cw.sources'
    31 
    31 
       
    32 
       
    33 # repo sources synchronization #################################################
    32 
    34 
    33 class SourceAddedOp(hook.Operation):
    35 class SourceAddedOp(hook.Operation):
    34     def postcommit_event(self):
    36     def postcommit_event(self):
    35         self.session.repo.add_source(self.entity)
    37         self.session.repo.add_source(self.entity)
    36 
    38 
    98             except IndexError:
   100             except IndexError:
    99                 # XXX no source linked to the host config yet
   101                 # XXX no source linked to the host config yet
   100                 pass
   102                 pass
   101 
   103 
   102 
   104 
   103 # source mapping synchronization. Expect cw_for_source/cw_schema are immutable
   105 # source mapping synchronization ###############################################
   104 # relations (i.e. can't change from a source or schema to another).
   106 #
       
   107 # Expect cw_for_source/cw_schema are immutable relations (i.e. can't change from
       
   108 # a source or schema to another).
   105 
   109 
   106 class SourceMappingDeleteHook(SourceHook):
   110 class SourceMappingDeleteHook(SourceHook):
   107     """check cw_for_source and cw_schema are immutable relations
   111     """check cw_for_source and cw_schema are immutable relations
   108 
   112 
   109     XXX empty delete perms would be enough?
   113     XXX empty delete perms would be enough?
   159     events = ('before_delete_relation',)
   163     events = ('before_delete_relation',)
   160     def __call__(self):
   164     def __call__(self):
   161         SourceMappingChangedOp.get_instance(self._cw).add_data(
   165         SourceMappingChangedOp.get_instance(self._cw).add_data(
   162             (self._cw.entity_from_eid(self.eidfrom),
   166             (self._cw.entity_from_eid(self.eidfrom),
   163              self._cw.entity_from_eid(self.eidto)) )
   167              self._cw.entity_from_eid(self.eidto)) )
       
   168