diff --git a/CHANGELOG b/CHANGELOG index e3c7775a8c..325b864912 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Add cached_property in tools * Use custom class to store record data * Add configuration check * Add support for properties to fields.depends diff --git a/trytond/protocols/jsonrpc.py b/trytond/protocols/jsonrpc.py index b81735f0e5..e7e2dbc432 100644 --- a/trytond/protocols/jsonrpc.py +++ b/trytond/protocols/jsonrpc.py @@ -6,7 +6,6 @@ import json import base64 from werkzeug.wrappers import Response -from werkzeug.utils import cached_property from werkzeug.exceptions import ( BadRequest, InternalServerError, Conflict, Forbidden, Locked, TooManyRequests) @@ -15,6 +14,7 @@ from trytond.protocols.wrappers import Request from trytond.exceptions import ( TrytonException, UserWarning, LoginException, ConcurrencyException, RateLimitException, MissingDependenciesException) +from trytond.tools import cached_property class JSONDecoder(object): diff --git a/trytond/protocols/wrappers.py b/trytond/protocols/wrappers.py index 79a2c44431..d9c49d493d 100644 --- a/trytond/protocols/wrappers.py +++ b/trytond/protocols/wrappers.py @@ -12,7 +12,6 @@ except ImportError: from http import client as HTTPStatus from werkzeug.wrappers import Request as _Request, Response -from werkzeug.utils import cached_property from werkzeug.http import wsgi_to_bytes, bytes_to_wsgi from werkzeug.datastructures import Authorization from werkzeug.exceptions import abort, HTTPException @@ -20,6 +19,7 @@ from werkzeug.exceptions import abort, HTTPException from trytond import security, backend from trytond.exceptions import RateLimitException from trytond.pool import Pool +from trytond.tools import cached_property from trytond.transaction import Transaction from trytond.config import config diff --git a/trytond/protocols/xmlrpc.py b/trytond/protocols/xmlrpc.py index 5df5fc5f69..ce27dc05c1 100644 --- a/trytond/protocols/xmlrpc.py +++ b/trytond/protocols/xmlrpc.py @@ -8,7 +8,6 @@ import logging from decimal import Decimal from werkzeug.wrappers import Response -from werkzeug.utils import cached_property from werkzeug.exceptions import ( BadRequest, InternalServerError, Conflict, Forbidden, Locked, TooManyRequests) @@ -17,6 +16,7 @@ from trytond.protocols.wrappers import Request from trytond.exceptions import ( TrytonException, UserWarning, LoginException, ConcurrencyException, RateLimitException, MissingDependenciesException) +from trytond.tools import cached_property logger = logging.getLogger(__name__) diff --git a/trytond/tools/__init__.py b/trytond/tools/__init__.py index 89bb3743a4..c7cd75443e 100644 --- a/trytond/tools/__init__.py +++ b/trytond/tools/__init__.py @@ -1,5 +1,9 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. +try: + from functools import cached_property +except ImportError: + from werkzeug.utils import cached_property from .misc import ( file_open, get_smtp_server, reduce_ids, reduce_domain, @@ -10,7 +14,7 @@ from .decimal_ import decistmt __all__ = ['file_open', 'get_smtp_server', 'reduce_ids', 'reduce_domain', 'grouped_slice', 'is_instance_method', 'resolve', 'strip_wildcard', 'lstrip_wildcard', 'rstrip_wildcard', 'slugify', - 'decistmt', 'ClassProperty', 'cursor_dict'] + 'decistmt', 'ClassProperty', 'cursor_dict', 'cached_property'] class ClassProperty(property):