equal
deleted
inserted
replaced
35 from cubicweb import Binary, UnknownEid, QueryError, schema |
35 from cubicweb import Binary, UnknownEid, QueryError, schema |
36 from cubicweb.req import RequestSessionBase |
36 from cubicweb.req import RequestSessionBase |
37 from cubicweb.dbapi import ConnectionProperties |
37 from cubicweb.dbapi import ConnectionProperties |
38 from cubicweb.utils import make_uid, RepeatList |
38 from cubicweb.utils import make_uid, RepeatList |
39 from cubicweb.rqlrewrite import RQLRewriter |
39 from cubicweb.rqlrewrite import RQLRewriter |
|
40 from cubicweb.server.edition import EditedEntity |
40 |
41 |
41 ETYPE_PYOBJ_MAP[Binary] = 'Bytes' |
42 ETYPE_PYOBJ_MAP[Binary] = 'Bytes' |
42 |
43 |
43 NO_UNDO_TYPES = schema.SCHEMA_TYPES.copy() |
44 NO_UNDO_TYPES = schema.SCHEMA_TYPES.copy() |
44 NO_UNDO_TYPES.add('CWCache') |
45 NO_UNDO_TYPES.add('CWCache') |
213 want to add. |
214 want to add. |
214 """ |
215 """ |
215 with security_enabled(self, False, False): |
216 with security_enabled(self, False, False): |
216 if self.vreg.schema[rtype].inlined: |
217 if self.vreg.schema[rtype].inlined: |
217 entity = self.entity_from_eid(fromeid) |
218 entity = self.entity_from_eid(fromeid) |
218 entity[rtype] = toeid |
219 edited = EditedEntity(entity) |
219 self.repo.glob_update_entity(self, entity, set((rtype,))) |
220 edited.edited_attribute(rtype, toeid) |
|
221 self.repo.glob_update_entity(self, edited) |
220 else: |
222 else: |
221 self.repo.glob_add_relation(self, fromeid, rtype, toeid) |
223 self.repo.glob_add_relation(self, fromeid, rtype, toeid) |
222 |
224 |
223 def delete_relation(self, fromeid, rtype, toeid): |
225 def delete_relation(self, fromeid, rtype, toeid): |
224 """provide direct access to the repository method to delete a relation. |
226 """provide direct access to the repository method to delete a relation. |
232 want to delete. |
234 want to delete. |
233 """ |
235 """ |
234 with security_enabled(self, False, False): |
236 with security_enabled(self, False, False): |
235 if self.vreg.schema[rtype].inlined: |
237 if self.vreg.schema[rtype].inlined: |
236 entity = self.entity_from_eid(fromeid) |
238 entity = self.entity_from_eid(fromeid) |
237 entity[rtype] = None |
239 entity.cw_attr_cache[rtype] = None |
238 self.repo.glob_update_entity(self, entity, set((rtype,))) |
240 self.repo.glob_update_entity(self, entity, set((rtype,))) |
239 else: |
241 else: |
240 self.repo.glob_delete_relation(self, fromeid, rtype, toeid) |
242 self.repo.glob_delete_relation(self, fromeid, rtype, toeid) |
241 |
243 |
242 # relations cache handling ################################################# |
244 # relations cache handling ################################################# |