server/sources/native.py
branchstable
changeset 5098 32b1adfb6b92
parent 5076 b0e6134b4324
child 5107 3694bd379513
equal deleted inserted replaced
5097:60a237638f57 5098:32b1adfb6b92
  1029         # get an entity instance
  1029         # get an entity instance
  1030         try:
  1030         try:
  1031             entity = self.repo.vreg['etypes'].etype_class(etype)(session)
  1031             entity = self.repo.vreg['etypes'].etype_class(etype)(session)
  1032         except Exception:
  1032         except Exception:
  1033             return [session._(
  1033             return [session._(
  1034                 "Can't undo creation of entity %s of type %s, type "
  1034                 "Can't undo creation of entity %(eid)s of type %(etype)s, type "
  1035                 "no more supported" % (eid, etype))]
  1035                 "no more supported" % {'eid': eid, 'etype': etype})]
  1036         entity.set_eid(eid)
  1036         entity.set_eid(eid)
  1037         # for proper eid/type cache update
  1037         # for proper eid/type cache update
  1038         hook.set_operation(session, 'pendingeids', eid,
  1038         hook.set_operation(session, 'pendingeids', eid,
  1039                            CleanupDeletedEidsCacheOp)
  1039                            CleanupDeletedEidsCacheOp)
  1040         self.repo.hm.call_hooks('before_delete_entity', session, entity=entity)
  1040         self.repo.hm.call_hooks('before_delete_entity', session, entity=entity)
  1073                 sql = 'SELECT 1 FROM %s_relation WHERE eid_from=%s and eid_to=%s'\
  1073                 sql = 'SELECT 1 FROM %s_relation WHERE eid_from=%s and eid_to=%s'\
  1074                       % (rtype, subj, obj)
  1074                       % (rtype, subj, obj)
  1075             cu = self.doexec(session, sql)
  1075             cu = self.doexec(session, sql)
  1076             if cu.fetchone() is None:
  1076             if cu.fetchone() is None:
  1077                 errors.append(session._(
  1077                 errors.append(session._(
  1078                     "Can't undo addition of relation %s from %s to %s, doesn't "
  1078                     "Can't undo addition of relation %(rtype)s from %(subj)s to"
  1079                     "exist anymore" % (rtype, subj, obj)))
  1079                     " %(obj)s, doesn't exist anymore" % locals()))
  1080         if not errors:
  1080         if not errors:
  1081             self.repo.hm.call_hooks('before_delete_relation', session,
  1081             self.repo.hm.call_hooks('before_delete_relation', session,
  1082                                     eidfrom=subj, rtype=rtype, eidto=obj)
  1082                                     eidfrom=subj, rtype=rtype, eidto=obj)
  1083             # delete relation from the database
  1083             # delete relation from the database
  1084             self._delete_relation(session, subj, rtype, obj, rschema.inlined)
  1084             self._delete_relation(session, subj, rtype, obj, rschema.inlined)