# HG changeset patch # User Pierre-Yves David # Date 1363977145 -3600 # Node ID 2005dcc6150e71b5830d70f1e8ab0f8ba43eac36 # Parent 1672502ac204822b5549d328b68092cf921ef5bb [transaction] relocate method building transaction context manager It is in the middle of methods going to be refactored. diff -r 1672502ac204 -r 2005dcc6150e server/session.py --- a/server/session.py Fri Mar 22 18:49:48 2013 +0100 +++ b/server/session.py Fri Mar 22 19:32:25 2013 +0100 @@ -393,16 +393,6 @@ return '' % ( unicode(self.user.login), self.id, id(self)) - def transaction(self, free_cnxset=True): - """return context manager to enter a transaction for the session: when - exiting the `with` block on exception, call `session.rollback()`, else - call `session.commit()` on normal exit. - - The `free_cnxset` will be given to rollback/commit methods to indicate - wether the connections set should be freed or not. - """ - return transaction(self, free_cnxset) - def set_tx_data(self, txid=None): if txid is None: txid = threading.currentThread().getName() @@ -424,6 +414,17 @@ def get_option_value(self, option, foreid=None): return self.repo.get_option_value(option, foreid) + def transaction(self, free_cnxset=True): + """return context manager to enter a transaction for the session: when + exiting the `with` block on exception, call `session.rollback()`, else + call `session.commit()` on normal exit. + + The `free_cnxset` will be given to rollback/commit methods to indicate + wether the connections set should be freed or not. + """ + return transaction(self, free_cnxset) + + def hijack_user(self, user): """return a fake request/session using specified user""" session = Session(user, self.repo)