hooks/syncsession.py
branchstable
changeset 7677 134613d3b353
parent 7398 26695dd703d8
child 7879 9aae456abab5
equal deleted inserted replaced
7670:6397a9051f65 7677:134613d3b353
    54 
    54 
    55 
    55 
    56 class _DeleteGroupOp(_GroupOperation):
    56 class _DeleteGroupOp(_GroupOperation):
    57     """synchronize user when a in_group relation has been deleted"""
    57     """synchronize user when a in_group relation has been deleted"""
    58     def postcommit_event(self):
    58     def postcommit_event(self):
    59         """the observed connections pool has been commited"""
    59         """the observed connections set has been commited"""
    60         groups = self.cnxuser.groups
    60         groups = self.cnxuser.groups
    61         try:
    61         try:
    62             groups.remove(self.group)
    62             groups.remove(self.group)
    63         except KeyError:
    63         except KeyError:
    64             self.error('user %s not in group %s',  self.cnxuser, self.group)
    64             self.error('user %s not in group %s',  self.cnxuser, self.group)
    65 
    65 
    66 
    66 
    67 class _AddGroupOp(_GroupOperation):
    67 class _AddGroupOp(_GroupOperation):
    68     """synchronize user when a in_group relation has been added"""
    68     """synchronize user when a in_group relation has been added"""
    69     def postcommit_event(self):
    69     def postcommit_event(self):
    70         """the observed connections pool has been commited"""
    70         """the observed connections set has been commited"""
    71         groups = self.cnxuser.groups
    71         groups = self.cnxuser.groups
    72         if self.group in groups:
    72         if self.group in groups:
    73             self.warning('user %s already in group %s', self.cnxuser,
    73             self.warning('user %s already in group %s', self.cnxuser,
    74                          self.group)
    74                          self.group)
    75         else:
    75         else:
    95     def __init__(self, session, cnxid):
    95     def __init__(self, session, cnxid):
    96         self.cnxid = cnxid
    96         self.cnxid = cnxid
    97         hook.Operation.__init__(self, session)
    97         hook.Operation.__init__(self, session)
    98 
    98 
    99     def postcommit_event(self):
    99     def postcommit_event(self):
   100         """the observed connections pool has been commited"""
   100         """the observed connections set has been commited"""
   101         try:
   101         try:
   102             self.session.repo.close(self.cnxid)
   102             self.session.repo.close(self.cnxid)
   103         except BadConnectionId:
   103         except BadConnectionId:
   104             pass # already closed
   104             pass # already closed
   105 
   105 
   120 
   120 
   121 class _DelCWPropertyOp(hook.Operation):
   121 class _DelCWPropertyOp(hook.Operation):
   122     """a user's custom properties has been deleted"""
   122     """a user's custom properties has been deleted"""
   123 
   123 
   124     def postcommit_event(self):
   124     def postcommit_event(self):
   125         """the observed connections pool has been commited"""
   125         """the observed connections set has been commited"""
   126         try:
   126         try:
   127             del self.cwpropdict[self.key]
   127             del self.cwpropdict[self.key]
   128         except KeyError:
   128         except KeyError:
   129             self.error('%s has no associated value', self.key)
   129             self.error('%s has no associated value', self.key)
   130 
   130 
   131 
   131 
   132 class _ChangeCWPropertyOp(hook.Operation):
   132 class _ChangeCWPropertyOp(hook.Operation):
   133     """a user's custom properties has been added/changed"""
   133     """a user's custom properties has been added/changed"""
   134 
   134 
   135     def postcommit_event(self):
   135     def postcommit_event(self):
   136         """the observed connections pool has been commited"""
   136         """the observed connections set has been commited"""
   137         self.cwpropdict[self.key] = self.value
   137         self.cwpropdict[self.key] = self.value
   138 
   138 
   139 
   139 
   140 class _AddCWPropertyOp(hook.Operation):
   140 class _AddCWPropertyOp(hook.Operation):
   141     """a user's custom properties has been added/changed"""
   141     """a user's custom properties has been added/changed"""
   142 
   142 
   143     def postcommit_event(self):
   143     def postcommit_event(self):
   144         """the observed connections pool has been commited"""
   144         """the observed connections set has been commited"""
   145         cwprop = self.cwprop
   145         cwprop = self.cwprop
   146         if not cwprop.for_user:
   146         if not cwprop.for_user:
   147             self.session.vreg['propertyvalues'][cwprop.pkey] = cwprop.value
   147             self.session.vreg['propertyvalues'][cwprop.pkey] = cwprop.value
   148         # if for_user is set, update is handled by a ChangeCWPropertyOp operation
   148         # if for_user is set, update is handled by a ChangeCWPropertyOp operation
   149 
   149