hooks/syncschema.py
changeset 9469 032825bbacab
parent 9463 d62e13eba033
child 9548 be001628edad
equal deleted inserted replaced
9468:39b7a91a3f4c 9469:032825bbacab
   292                                         SQL_PREFIX+newname)
   292                                         SQL_PREFIX+newname)
   293         sqlexec(sql)
   293         sqlexec(sql)
   294         self.info('renamed table %s to %s', oldname, newname)
   294         self.info('renamed table %s to %s', oldname, newname)
   295         sqlexec('UPDATE entities SET type=%(newname)s WHERE type=%(oldname)s',
   295         sqlexec('UPDATE entities SET type=%(newname)s WHERE type=%(oldname)s',
   296                 {'newname': newname, 'oldname': oldname})
   296                 {'newname': newname, 'oldname': oldname})
   297         for eid, (etype, uri, extid, auri) in self.session.repo._type_source_cache.items():
   297         for eid, (etype, extid, auri) in self.session.repo._type_source_cache.items():
   298             if etype == oldname:
   298             if etype == oldname:
   299                 self.session.repo._type_source_cache[eid] = (newname, uri, extid, auri)
   299                 self.session.repo._type_source_cache[eid] = (newname, extid, auri)
   300         # XXX transaction records
   300         # XXX transaction records
   301 
   301 
   302     def precommit_event(self):
   302     def precommit_event(self):
   303         self.rename(self.oldname, self.newname)
   303         self.rename(self.oldname, self.newname)
   304 
   304 
  1178         'update_permission')
  1178         'update_permission')
  1179     events = ('after_add_relation',)
  1179     events = ('after_add_relation',)
  1180 
  1180 
  1181     def __call__(self):
  1181     def __call__(self):
  1182         action = self.rtype.split('_', 1)[0]
  1182         action = self.rtype.split('_', 1)[0]
  1183         if self._cw.describe(self.eidto)[0] == 'CWGroup':
  1183         if self._cw.entity_metas(self.eidto)['type'] == 'CWGroup':
  1184             MemSchemaPermissionAdd(self._cw, action=action, eid=self.eidfrom,
  1184             MemSchemaPermissionAdd(self._cw, action=action, eid=self.eidfrom,
  1185                                    group_eid=self.eidto)
  1185                                    group_eid=self.eidto)
  1186         else: # RQLExpression
  1186         else: # RQLExpression
  1187             expr = self._cw.entity_from_eid(self.eidto).expression
  1187             expr = self._cw.entity_from_eid(self.eidto).expression
  1188             MemSchemaPermissionAdd(self._cw, action=action, eid=self.eidfrom,
  1188             MemSchemaPermissionAdd(self._cw, action=action, eid=self.eidfrom,
  1199 
  1199 
  1200     def __call__(self):
  1200     def __call__(self):
  1201         if self._cw.deleted_in_transaction(self.eidfrom):
  1201         if self._cw.deleted_in_transaction(self.eidfrom):
  1202             return
  1202             return
  1203         action = self.rtype.split('_', 1)[0]
  1203         action = self.rtype.split('_', 1)[0]
  1204         if self._cw.describe(self.eidto)[0] == 'CWGroup':
  1204         if self._cw.entity_metas(self.eidto)['type'] == 'CWGroup':
  1205             MemSchemaPermissionDel(self._cw, action=action, eid=self.eidfrom,
  1205             MemSchemaPermissionDel(self._cw, action=action, eid=self.eidfrom,
  1206                                    group_eid=self.eidto)
  1206                                    group_eid=self.eidto)
  1207         else: # RQLExpression
  1207         else: # RQLExpression
  1208             expr = self._cw.entity_from_eid(self.eidto).expression
  1208             expr = self._cw.entity_from_eid(self.eidto).expression
  1209             MemSchemaPermissionDel(self._cw, action=action, eid=self.eidfrom,
  1209             MemSchemaPermissionDel(self._cw, action=action, eid=self.eidfrom,