45 for asession in session.repo._sessions.itervalues(): |
45 for asession in session.repo._sessions.itervalues(): |
46 if asession.user.eid == object: |
46 if asession.user.eid == object: |
47 asession.user.clear_related_cache(rtype, 'object') |
47 asession.user.clear_related_cache(rtype, 'object') |
48 |
48 |
49 def _mark_modified(session, gaeentity): |
49 def _mark_modified(session, gaeentity): |
50 modified = session.query_data('modifiedentities', {}, setdefault=True) |
50 modified = session.transaction_data.setdefault('modifiedentities', {}) |
51 modified[str(gaeentity.key())] = gaeentity |
51 modified[str(gaeentity.key())] = gaeentity |
52 DatastorePutOp(session) |
52 DatastorePutOp(session) |
53 |
53 |
54 def _rinfo(session, subject, rtype, object): |
54 def _rinfo(session, subject, rtype, object): |
55 gaesubj = session.datastore_get(subject) |
55 gaesubj = session.datastore_get(subject) |
96 """ |
96 """ |
97 def insert_index(self): |
97 def insert_index(self): |
98 return 0 |
98 return 0 |
99 |
99 |
100 def _put_entities(self): |
100 def _put_entities(self): |
101 pending = self.session.query_data('pendingeids', ()) |
101 pending = self.session.transaction_data.get('pendingeids', ()) |
102 modified = self.session.query_data('modifiedentities', {}) |
102 modified = self.session.transaction_data.get('modifiedentities', {}) |
103 for eid, gaeentity in modified.iteritems(): |
103 for eid, gaeentity in modified.iteritems(): |
104 assert not eid in pending |
104 assert not eid in pending |
105 Put(gaeentity) |
105 Put(gaeentity) |
106 modified.clear() |
106 modified.clear() |
107 |
107 |
261 # consistency |
261 # consistency |
262 key = Key(eid) |
262 key = Key(eid) |
263 Delete(key) |
263 Delete(key) |
264 session.clear_datastore_cache(key) |
264 session.clear_datastore_cache(key) |
265 session.drop_entity_cache(eid) |
265 session.drop_entity_cache(eid) |
266 session.query_data('modifiedentities', {}).pop(eid, None) |
266 session.transaction_data.get('modifiedentities', {}).pop(eid, None) |
267 |
267 |
268 def add_relation(self, session, subject, rtype, object): |
268 def add_relation(self, session, subject, rtype, object): |
269 """add a relation to the source""" |
269 """add a relation to the source""" |
270 gaesubj, gaeobj, cards = _rinfo(session, subject, rtype, object) |
270 gaesubj, gaeobj, cards = _rinfo(session, subject, rtype, object) |
271 _radd(session, gaesubj, gaeobj.key(), 's_' + rtype, cards[0]) |
271 _radd(session, gaesubj, gaeobj.key(), 's_' + rtype, cards[0]) |
273 _clear_related_cache(session, gaesubj, rtype, gaeobj) |
273 _clear_related_cache(session, gaesubj, rtype, gaeobj) |
274 |
274 |
275 def delete_relation(self, session, subject, rtype, object): |
275 def delete_relation(self, session, subject, rtype, object): |
276 """delete a relation from the source""" |
276 """delete a relation from the source""" |
277 gaesubj, gaeobj, cards = _rinfo(session, subject, rtype, object) |
277 gaesubj, gaeobj, cards = _rinfo(session, subject, rtype, object) |
278 pending = session.query_data('pendingeids', set(), setdefault=True) |
278 pending = session.transaction_data.setdefault('pendingeids', set()) |
279 if not subject in pending: |
279 if not subject in pending: |
280 _rdel(session, gaesubj, gaeobj.key(), 's_' + rtype, cards[0]) |
280 _rdel(session, gaesubj, gaeobj.key(), 's_' + rtype, cards[0]) |
281 if not object in pending: |
281 if not object in pending: |
282 _rdel(session, gaeobj, gaesubj.key(), 'o_' + rtype, cards[1]) |
282 _rdel(session, gaeobj, gaesubj.key(), 'o_' + rtype, cards[1]) |
283 _clear_related_cache(session, gaesubj, rtype, gaeobj) |
283 _clear_related_cache(session, gaesubj, rtype, gaeobj) |