From e2bd3e328aa0a4e2a438a3b0e9f3fc3fa5601b62 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 19 Jun 2019 14:19:01 +0000 Subject: [IMP] odoo: remove LazyCursor Was specifically created for decimal.precision at f0646cb51b236a3afd5 Should no longer be needed --- odoo/fields.py | 1 - odoo/sql_db.py | 34 ---------------------------------- odoo/tools/profiler.py | 2 +- 3 files changed, 1 insertion(+), 36 deletions(-) (limited to 'odoo') diff --git a/odoo/fields.py b/odoo/fields.py index 8c5eee7682f..c95cb00eb85 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -22,7 +22,6 @@ except ImportError: import psycopg2 -from .sql_db import LazyCursor from .tools import float_repr, float_round, frozendict, html_sanitize, human_size, pg_varchar, \ ustr, OrderedSet, pycompat, sql, date_utils, unique, IterableGenerator from .tools import DEFAULT_SERVER_DATE_FORMAT as DATE_FORMAT 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 diff --git a/odoo/tools/profiler.py b/odoo/tools/profiler.py index dce9f98fb44..0904faf3c1b 100644 --- a/odoo/tools/profiler.py +++ b/odoo/tools/profiler.py @@ -35,7 +35,7 @@ class _LogTracer(object): in_self = frame.f_locals['self'] - if isinstance(in_self, (odoo.sql_db.Cursor, odoo.sql_db.TestCursor, odoo.sql_db.LazyCursor)): + if isinstance(in_self, (odoo.sql_db.Cursor, odoo.sql_db.TestCursor)): return self.tracer model = getattr(in_self, '_name', None) -- cgit v1.2.3