diff options
| author | Martin Trigaux <mat@odoo.com> | 2019-06-19 14:19:01 +0000 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2019-07-03 11:16:24 +0000 |
| commit | e2bd3e328aa0a4e2a438a3b0e9f3fc3fa5601b62 (patch) | |
| tree | e8ea69368ee309b1dca0ba2f0fe3824b203d7251 /odoo/sql_db.py | |
| parent | dd2fae2ead6ea00dfc7e7a6e1d3a0a5624e478f7 (diff) | |
[IMP] odoo: remove LazyCursor
Was specifically created for decimal.precision at f0646cb51b236a3afd5
Should no longer be needed
Diffstat (limited to 'odoo/sql_db.py')
| -rw-r--r-- | odoo/sql_db.py | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/odoo/sql_db.py b/odoo/sql_db.py index a21890f69f5..debc9f48c42 100644 --- a/odoo/sql_db.py +++ b/odoo/sql_db.py @@ -483,40 +483,6 @@ class TestCursor(object): return value -class LazyCursor(object): - """ A proxy object to a cursor. The cursor itself is allocated only if it is - needed. This class is useful for cached methods, that use the cursor - only in the case of a cache miss. - """ - def __init__(self, dbname=None): - self._dbname = dbname - self._cursor = None - self._depth = 0 - - @property - def dbname(self): - return self._dbname or threading.currentThread().dbname - - def __getattr__(self, name): - cr = self._cursor - if cr is None: - from odoo import registry - cr = self._cursor = registry(self.dbname).cursor() - for _ in range(self._depth): - cr.__enter__() - return getattr(cr, name) - - def __enter__(self): - self._depth += 1 - if self._cursor is not None: - self._cursor.__enter__() - return self - - def __exit__(self, exc_type, exc_value, traceback): - self._depth -= 1 - if self._cursor is not None: - self._cursor.__exit__(exc_type, exc_value, traceback) - class PsycoConnection(psycopg2.extensions.connection): pass |
