# HG changeset patch # User Sylvain Thénault # Date 1244740230 -7200 # Node ID 2686599077694295afa477a53b87a353196f711e # Parent 08003e0354a7c8be1ae106cfe7a2dbd437e6e635 finish to update transaction data api diff -r 08003e0354a7 -r 268659907769 goa/gaesource.py --- a/goa/gaesource.py Thu Jun 11 19:07:47 2009 +0200 +++ b/goa/gaesource.py Thu Jun 11 19:10:30 2009 +0200 @@ -47,7 +47,7 @@ asession.user.clear_related_cache(rtype, 'object') def _mark_modified(session, gaeentity): - modified = session.query_data('modifiedentities', {}, setdefault=True) + modified = session.transaction_data.setdefault('modifiedentities', {}) modified[str(gaeentity.key())] = gaeentity DatastorePutOp(session) @@ -98,8 +98,8 @@ return 0 def _put_entities(self): - pending = self.session.query_data('pendingeids', ()) - modified = self.session.query_data('modifiedentities', {}) + pending = self.session.transaction_data.get('pendingeids', ()) + modified = self.session.transaction_data.get('modifiedentities', {}) for eid, gaeentity in modified.iteritems(): assert not eid in pending Put(gaeentity) @@ -263,7 +263,7 @@ Delete(key) session.clear_datastore_cache(key) session.drop_entity_cache(eid) - session.query_data('modifiedentities', {}).pop(eid, None) + session.transaction_data.get('modifiedentities', {}).pop(eid, None) def add_relation(self, session, subject, rtype, object): """add a relation to the source""" @@ -275,7 +275,7 @@ def delete_relation(self, session, subject, rtype, object): """delete a relation from the source""" gaesubj, gaeobj, cards = _rinfo(session, subject, rtype, object) - pending = session.query_data('pendingeids', set(), setdefault=True) + pending = session.transaction_data.setdefault('pendingeids', set()) if not subject in pending: _rdel(session, gaesubj, gaeobj.key(), 's_' + rtype, cards[0]) if not object in pending: diff -r 08003e0354a7 -r 268659907769 server/hookhelper.py --- a/server/hookhelper.py Thu Jun 11 19:07:47 2009 +0200 +++ b/server/hookhelper.py Thu Jun 11 19:10:30 2009 +0200 @@ -100,7 +100,8 @@ relation hooks, the relation may has been deleted at this point, so we have handle that """ - for eidfrom, rtype, eidto in reversed(session.query_data('pendingrelations', ())): + pending = session.transaction_data.get('pendingrelations', ()) + for eidfrom, rtype, eidto in reversed(pending): if rtype == 'in_state' and eidfrom == eid: rset = session.execute('Any S,N WHERE S eid %(x)s, S name N', {'x': eidto}, 'x') diff -r 08003e0354a7 -r 268659907769 sobjects/notification.py --- a/sobjects/notification.py Thu Jun 11 19:07:47 2009 +0200 +++ b/sobjects/notification.py Thu Jun 11 19:10:30 2009 +0200 @@ -62,7 +62,7 @@ class RenderAndSendNotificationView(PreCommitOperation): """delay rendering of notification view until precommit""" def precommit_event(self): - if self.view.rset[0][0] in self.session.query_data('pendingeids', ()): + if self.view.rset[0][0] in self.session.transaction_data.get('pendingeids', ()): return # entity added and deleted in the same transaction self.view.render_and_send(**getattr(self, 'viewargs', {})) diff -r 08003e0354a7 -r 268659907769 sobjects/supervising.py --- a/sobjects/supervising.py Thu Jun 11 19:07:47 2009 +0200 +++ b/sobjects/supervising.py Thu Jun 11 19:10:30 2009 +0200 @@ -226,7 +226,7 @@ uinfo = {'email': config['sender-addr'], 'name': config['sender-name']} view = self._get_view() - content = view.render(changes=session.query_data('pendingchanges')) + content = view.render(changes=session.transaction_data.get('pendingchanges')) recipients = view.recipients() msg = format_mail(uinfo, recipients, content, view.subject(), config=config) self.to_send = [(msg, recipients)] diff -r 08003e0354a7 -r 268659907769 sobjects/test/unittest_supervising.py --- a/sobjects/test/unittest_supervising.py Thu Jun 11 19:07:47 2009 +0200 +++ b/sobjects/test/unittest_supervising.py Thu Jun 11 19:10:30 2009 +0200 @@ -45,7 +45,7 @@ view = sentops[0]._get_view() self.assertEquals(view.recipients(), ['test@logilab.fr']) self.assertEquals(view.subject(), '[data supervision] changes summary') - data = view.render(changes=session.query_data('pendingchanges')).strip() + data = view.render(changes=session.transaction_data.get('pendingchanges')).strip() data = re.sub('#\d+', '#EID', data) data = re.sub('/\d+', '/EID', data) self.assertTextEquals('''user admin has made the following change(s):