server/sources/native.py
changeset 5557 1a534c596bff
parent 5556 9ab2b4c74baf
child 5627 a7e40cccdc9b
equal deleted inserted replaced
5556:9ab2b4c74baf 5557:1a534c596bff
  1005                 entity[rtype] = Binary(value)
  1005                 entity[rtype] = Binary(value)
  1006             elif isinstance(value, str):
  1006             elif isinstance(value, str):
  1007                 entity[rtype] = unicode(value, session.encoding, 'replace')
  1007                 entity[rtype] = unicode(value, session.encoding, 'replace')
  1008             else:
  1008             else:
  1009                 entity[rtype] = value
  1009                 entity[rtype] = value
  1010         entity.set_eid(eid)
  1010         entity.eid = eid
  1011         session.repo.init_entity_caches(session, entity, self)
  1011         session.repo.init_entity_caches(session, entity, self)
  1012         entity.edited_attributes = set(entity)
  1012         entity.edited_attributes = set(entity)
  1013         entity.check()
  1013         entity._cw_check()
  1014         self.repo.hm.call_hooks('before_add_entity', session, entity=entity)
  1014         self.repo.hm.call_hooks('before_add_entity', session, entity=entity)
  1015         # restore the entity
  1015         # restore the entity
  1016         action.changes['cw_eid'] = eid
  1016         action.changes['cw_eid'] = eid
  1017         sql = self.sqlgen.insert(SQL_PREFIX + etype, action.changes)
  1017         sql = self.sqlgen.insert(SQL_PREFIX + etype, action.changes)
  1018         self.doexec(session, sql, action.changes)
  1018         self.doexec(session, sql, action.changes)
  1075             entity = self.repo.vreg['etypes'].etype_class(etype)(session)
  1075             entity = self.repo.vreg['etypes'].etype_class(etype)(session)
  1076         except Exception:
  1076         except Exception:
  1077             return [session._(
  1077             return [session._(
  1078                 "Can't undo creation of entity %(eid)s of type %(etype)s, type "
  1078                 "Can't undo creation of entity %(eid)s of type %(etype)s, type "
  1079                 "no more supported" % {'eid': eid, 'etype': etype})]
  1079                 "no more supported" % {'eid': eid, 'etype': etype})]
  1080         entity.set_eid(eid)
  1080         entity.eid = eid
  1081         # for proper eid/type cache update
  1081         # for proper eid/type cache update
  1082         hook.set_operation(session, 'pendingeids', eid,
  1082         hook.set_operation(session, 'pendingeids', eid,
  1083                            CleanupDeletedEidsCacheOp)
  1083                            CleanupDeletedEidsCacheOp)
  1084         self.repo.hm.call_hooks('before_delete_entity', session, entity=entity)
  1084         self.repo.hm.call_hooks('before_delete_entity', session, entity=entity)
  1085         # remove is / is_instance_of which are added using sql by hooks, hence
  1085         # remove is / is_instance_of which are added using sql by hooks, hence