Commit 2b5b9c7c authored by niv-openerp's avatar niv-openerp

[imp] added shortcut to get the user context

parent 8f81640d
......@@ -155,6 +155,7 @@ class Connection(object):
self.connector = connector
self.set_login_info(database, login, password, user_id)
self.user_context = None
def set_login_info(self, database, login, password, user_id=None):
......@@ -190,6 +191,11 @@ class Connection(object):
if not self.user_id:
raise AuthenticationError("Authentication failure")
self.__logger.debug("Authenticated with user id %s", self.user_id)
def get_user_context(self):
if not self.user_context:
self.user_context = self.get_model('res.users').context_get()
return self.user_context
def get_model(self, model_name):
......@@ -52,6 +52,11 @@ class TestSequenceFunctions(unittest.TestCase):
self.assertEqual(res['id'], 1)
def test_user_context(self):
connection = self.conn()
if __name__ == '__main__':
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment