# HG changeset patch # User Pierre-Yves David # Date 1364575154 -3600 # Node ID 168cf5ef21f850acf0e3815d1244c85a69b9108e # Parent ea05b8545dd8ae8070d8c78c39ef9661a85ef568 [session/transaction] move multiple utility on Transaction diff -r ea05b8545dd8 -r 168cf5ef21f8 server/session.py --- a/server/session.py Fri Mar 29 17:25:56 2013 +0100 +++ b/server/session.py Fri Mar 29 17:39:14 2013 +0100 @@ -646,6 +646,23 @@ num = self.data.setdefault('tx_action_count', 0) + 1 self.data['tx_action_count'] = num return num + # db-api like interface ################################################### + + def source_defs(self): + return self.repo.source_defs() + + def describe(self, eid, asdict=False): + """return a tuple (type, sourceuri, extid) for the entity with id """ + metas = self.repo.type_and_source_from_eid(eid, self) + if asdict: + return dict(zip(('type', 'source', 'extid', 'asource'), metas)) + # XXX :-1 for cw compat, use asdict=True for full information + return metas[:-1] + + + def source_from_eid(self, eid): + """return the source where the entity with id is located""" + return self.repo.source_from_eid(eid, self) def tx_attr(attr_name, writable=False): @@ -1141,22 +1158,10 @@ """ return 'view' - def source_defs(self): - return self.repo.source_defs() + source_defs = tx_meth('source_defs') + describe = tx_meth('describe') + source_from_eid = tx_meth('source_from_eid') - def describe(self, eid, asdict=False): - """return a tuple (type, sourceuri, extid) for the entity with id """ - metas = self.repo.type_and_source_from_eid(eid, self) - if asdict: - return dict(zip(('type', 'source', 'extid', 'asource'), metas)) - # XXX :-1 for cw compat, use asdict=True for full information - return metas[:-1] - - # db-api like interface ################################################### - - def source_from_eid(self, eid): - """return the source where the entity with id is located""" - return self.repo.source_from_eid(eid, self) def execute(self, rql, kwargs=None, eid_key=None, build_descr=True): """db-api like method directly linked to the querier execute method.