Skip to content

Commit 1b46235

Browse files
committed
Merge PR #109 into 18.0
Signed-off-by simahawk
2 parents 1c58e1e + 9ae1efe commit 1b46235

File tree

16 files changed

+1198
-0
lines changed

16 files changed

+1198
-0
lines changed

endpoint_cache/README.rst

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
==============
2+
Endpoint cache
3+
==============
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:55a24c03b01aadf746170d87e9ff3d84c17bb1d764f5e07800038134e212e5c6
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Alpha
16+
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
18+
:alt: License: LGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb--api-lightgray.png?logo=github
20+
:target: https://github.com/OCA/web-api/tree/18.0/endpoint_cache
21+
:alt: OCA/web-api
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/web-api-18-0/web-api-18-0-endpoint_cache
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/web-api&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
Technical module provide basic caching configuration and utils for
32+
endpoints.
33+
34+
.. IMPORTANT::
35+
This is an alpha version, the data model and design can change at any time without warning.
36+
Only for development or testing purpose, do not use in production.
37+
`More details on development status <https://odoo-community.org/page/development-status>`_
38+
39+
**Table of contents**
40+
41+
.. contents::
42+
:local:
43+
44+
Usage
45+
=====
46+
47+
Example of usage in an endpoint:
48+
49+
::
50+
51+
# get the name of the cache
52+
cache_name = endpoint._endpoint_cache_make_name("json")
53+
# check if the cache exists
54+
cached = endpoint._endpoint_cache_get(cache_name)
55+
if cached:
56+
result = cached
57+
else:
58+
result = json.dumps(env["my.model"]._get_a_very_expensive_computed_result())
59+
# cache does not exist, create it
60+
endpoint._endpoint_cache_store(cache_name, result)
61+
62+
resp = Response(result, content_type="application/json", status=200)
63+
result = dict(response=resp)
64+
65+
Bug Tracker
66+
===========
67+
68+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web-api/issues>`_.
69+
In case of trouble, please check there if your issue has already been reported.
70+
If you spotted it first, help us to smash it by providing a detailed and welcomed
71+
`feedback <https://github.com/OCA/web-api/issues/new?body=module:%20endpoint_cache%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
72+
73+
Do not contact contributors directly about support or help with technical issues.
74+
75+
Credits
76+
=======
77+
78+
Authors
79+
-------
80+
81+
* Camptocamp
82+
83+
Contributors
84+
------------
85+
86+
- Simone Orsi <simone.orsi@camptocamp.com>
87+
88+
Maintainers
89+
-----------
90+
91+
This module is maintained by the OCA.
92+
93+
.. image:: https://odoo-community.org/logo.png
94+
:alt: Odoo Community Association
95+
:target: https://odoo-community.org
96+
97+
OCA, or the Odoo Community Association, is a nonprofit organization whose
98+
mission is to support the collaborative development of Odoo features and
99+
promote its widespread use.
100+
101+
.. |maintainer-simahawk| image:: https://github.com/simahawk.png?size=40px
102+
:target: https://github.com/simahawk
103+
:alt: simahawk
104+
105+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
106+
107+
|maintainer-simahawk|
108+
109+
This module is part of the `OCA/web-api <https://github.com/OCA/web-api/tree/18.0/endpoint_cache>`_ project on GitHub.
110+
111+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

endpoint_cache/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

endpoint_cache/__manifest__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2024 Camptocamp SA
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
3+
4+
{
5+
"name": "Endpoint cache",
6+
"summary": """Provide basic caching utils for endpoints""",
7+
"version": "18.0.1.0.0",
8+
"license": "LGPL-3",
9+
"development_status": "Alpha",
10+
"author": "Camptocamp, Odoo Community Association (OCA)",
11+
"maintainers": ["simahawk"],
12+
"website": "https://github.com/OCA/web-api",
13+
"depends": ["endpoint"],
14+
"data": ["views/endpoint_view.xml"],
15+
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * endpoint_cache
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 14.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"Last-Translator: \n"
10+
"Language-Team: \n"
11+
"MIME-Version: 1.0\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: \n"
14+
"Plural-Forms: \n"
15+
16+
#. module: endpoint_cache
17+
#: model_terms:ir.ui.view,arch_db:endpoint_cache.endpoint_mixin_form_view
18+
msgid ""
19+
"# get the name of the cache\n"
20+
"cache_name = endpoint._endpoint_cache_make_name(\"json\")\n"
21+
"# check if the cache exists\n"
22+
"cached = endpoint._endpoint_cache_get(cache_name)\n"
23+
"if cached:\n"
24+
" result = cached\n"
25+
"else:\n"
26+
" result = json.dumps(env[\"my.model\"]._get_a_very_expensive_computed_result())\n"
27+
" # cache does not exist, create it0\n"
28+
" endpoint._endpoint_cache_store(cache_name, result)\n"
29+
"resp = Response(result, content_type=\"application/json\", status=200)\n"
30+
"result = dict(response=resp)"
31+
msgstr ""
32+
33+
#. module: endpoint_cache
34+
#: model_terms:ir.ui.view,arch_db:endpoint_cache.endpoint_mixin_form_view
35+
msgid "Cache"
36+
msgstr ""
37+
38+
#. module: endpoint_cache
39+
#: model:ir.model.fields,field_description:endpoint_cache.field_endpoint_endpoint__cache_policy
40+
#: model:ir.model.fields,field_description:endpoint_cache.field_endpoint_mixin__cache_policy
41+
msgid "Cache Policy"
42+
msgstr ""
43+
44+
#. module: endpoint_cache
45+
#: model:ir.model.fields,field_description:endpoint_cache.field_endpoint_endpoint__cache_att_count
46+
#: model:ir.model.fields,field_description:endpoint_cache.field_endpoint_mixin__cache_att_count
47+
msgid "Cache count"
48+
msgstr ""
49+
50+
#. module: endpoint_cache
51+
#: code:addons/endpoint_cache/models/endpoint_mixin.py:0
52+
#, python-format
53+
msgid "Cache name must start with 'endpoint_cache'"
54+
msgstr ""
55+
56+
#. module: endpoint_cache
57+
#: code:addons/endpoint_cache/models/endpoint_mixin.py:0
58+
#, python-format
59+
msgid "Cache results"
60+
msgstr ""
61+
62+
#. module: endpoint_cache
63+
#: model_terms:ir.ui.view,arch_db:endpoint_cache.endpoint_mixin_form_view
64+
msgid "Cache usage example"
65+
msgstr ""
66+
67+
#. module: endpoint_cache
68+
#: model:ir.model.fields.selection,name:endpoint_cache.selection__endpoint_endpoint__cache_policy__day
69+
#: model:ir.model.fields.selection,name:endpoint_cache.selection__endpoint_mixin__cache_policy__day
70+
msgid "Daily"
71+
msgstr ""
72+
73+
#. module: endpoint_cache
74+
#: model:ir.model.fields,field_description:endpoint_cache.field_endpoint_mixin__display_name
75+
msgid "Display Name"
76+
msgstr ""
77+
78+
#. module: endpoint_cache
79+
#: model:ir.model,name:endpoint_cache.model_endpoint_mixin
80+
msgid "Endpoint mixin"
81+
msgstr ""
82+
83+
#. module: endpoint_cache
84+
#: model:ir.model.fields,field_description:endpoint_cache.field_endpoint_mixin__id
85+
msgid "ID"
86+
msgstr ""
87+
88+
#. module: endpoint_cache
89+
#: model:ir.model.fields,field_description:endpoint_cache.field_endpoint_mixin____last_update
90+
msgid "Last Modified on"
91+
msgstr ""
92+
93+
#. module: endpoint_cache
94+
#: model:ir.model.fields.selection,name:endpoint_cache.selection__endpoint_endpoint__cache_policy__month
95+
#: model:ir.model.fields.selection,name:endpoint_cache.selection__endpoint_mixin__cache_policy__month
96+
msgid "Monthly"
97+
msgstr ""
98+
99+
#. module: endpoint_cache
100+
#: model_terms:ir.ui.view,arch_db:endpoint_cache.endpoint_mixin_form_view
101+
msgid "Pre-heat cache"
102+
msgstr ""
103+
104+
#. module: endpoint_cache
105+
#: model_terms:ir.ui.view,arch_db:endpoint_cache.endpoint_mixin_form_view
106+
msgid "Purge caches"
107+
msgstr ""
108+
109+
#. module: endpoint_cache
110+
#: model_terms:ir.ui.view,arch_db:endpoint_cache.endpoint_mixin_form_view
111+
msgid "View caches"
112+
msgstr ""
113+
114+
#. module: endpoint_cache
115+
#: model_terms:ir.ui.view,arch_db:endpoint_cache.endpoint_mixin_form_view
116+
msgid ""
117+
"Warning: this might take too long to complete if the endpoint uses expensive"
118+
" computations."
119+
msgstr ""
120+
121+
#. module: endpoint_cache
122+
#: model:ir.model.fields.selection,name:endpoint_cache.selection__endpoint_endpoint__cache_policy__week
123+
#: model:ir.model.fields.selection,name:endpoint_cache.selection__endpoint_mixin__cache_policy__week
124+
msgid "Weekly"
125+
msgstr ""

endpoint_cache/i18n/it.po

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * endpoint_cache
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 14.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"Last-Translator: Automatically generated\n"
10+
"Language-Team: none\n"
11+
"Language: it\n"
12+
"MIME-Version: 1.0\n"
13+
"Content-Type: text/plain; charset=UTF-8\n"
14+
"Content-Transfer-Encoding: \n"
15+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
16+
17+
#. module: endpoint_cache
18+
#: model_terms:ir.ui.view,arch_db:endpoint_cache.endpoint_mixin_form_view
19+
msgid ""
20+
"# get the name of the cache\n"
21+
"cache_name = endpoint._endpoint_cache_make_name(\"json\")\n"
22+
"# check if the cache exists\n"
23+
"cached = endpoint._endpoint_cache_get(cache_name)\n"
24+
"if cached:\n"
25+
" result = cached\n"
26+
"else:\n"
27+
" result = json.dumps(env[\"my.model\"]."
28+
"_get_a_very_expensive_computed_result())\n"
29+
" # cache does not exist, create it0\n"
30+
" endpoint._endpoint_cache_store(cache_name, result)\n"
31+
"resp = Response(result, content_type=\"application/json\", status=200)\n"
32+
"result = dict(response=resp)"
33+
msgstr ""
34+
35+
#. module: endpoint_cache
36+
#: model_terms:ir.ui.view,arch_db:endpoint_cache.endpoint_mixin_form_view
37+
msgid "Cache"
38+
msgstr ""
39+
40+
#. module: endpoint_cache
41+
#: model:ir.model.fields,field_description:endpoint_cache.field_endpoint_endpoint__cache_policy
42+
#: model:ir.model.fields,field_description:endpoint_cache.field_endpoint_mixin__cache_policy
43+
msgid "Cache Policy"
44+
msgstr ""
45+
46+
#. module: endpoint_cache
47+
#: model:ir.model.fields,field_description:endpoint_cache.field_endpoint_endpoint__cache_att_count
48+
#: model:ir.model.fields,field_description:endpoint_cache.field_endpoint_mixin__cache_att_count
49+
msgid "Cache count"
50+
msgstr ""
51+
52+
#. module: endpoint_cache
53+
#: code:addons/endpoint_cache/models/endpoint_mixin.py:0
54+
#, python-format
55+
msgid "Cache name must start with 'endpoint_cache'"
56+
msgstr ""
57+
58+
#. module: endpoint_cache
59+
#: code:addons/endpoint_cache/models/endpoint_mixin.py:0
60+
#, python-format
61+
msgid "Cache results"
62+
msgstr ""
63+
64+
#. module: endpoint_cache
65+
#: model_terms:ir.ui.view,arch_db:endpoint_cache.endpoint_mixin_form_view
66+
msgid "Cache usage example"
67+
msgstr ""
68+
69+
#. module: endpoint_cache
70+
#: model:ir.model.fields.selection,name:endpoint_cache.selection__endpoint_endpoint__cache_policy__day
71+
#: model:ir.model.fields.selection,name:endpoint_cache.selection__endpoint_mixin__cache_policy__day
72+
msgid "Daily"
73+
msgstr ""
74+
75+
#. module: endpoint_cache
76+
#: model:ir.model.fields,field_description:endpoint_cache.field_endpoint_mixin__display_name
77+
msgid "Display Name"
78+
msgstr ""
79+
80+
#. module: endpoint_cache
81+
#: model:ir.model,name:endpoint_cache.model_endpoint_mixin
82+
msgid "Endpoint mixin"
83+
msgstr ""
84+
85+
#. module: endpoint_cache
86+
#: model:ir.model.fields,field_description:endpoint_cache.field_endpoint_mixin__id
87+
msgid "ID"
88+
msgstr ""
89+
90+
#. module: endpoint_cache
91+
#: model:ir.model.fields,field_description:endpoint_cache.field_endpoint_mixin____last_update
92+
msgid "Last Modified on"
93+
msgstr ""
94+
95+
#. module: endpoint_cache
96+
#: model:ir.model.fields.selection,name:endpoint_cache.selection__endpoint_endpoint__cache_policy__month
97+
#: model:ir.model.fields.selection,name:endpoint_cache.selection__endpoint_mixin__cache_policy__month
98+
msgid "Monthly"
99+
msgstr ""
100+
101+
#. module: endpoint_cache
102+
#: model_terms:ir.ui.view,arch_db:endpoint_cache.endpoint_mixin_form_view
103+
msgid "Pre-heat cache"
104+
msgstr ""
105+
106+
#. module: endpoint_cache
107+
#: model_terms:ir.ui.view,arch_db:endpoint_cache.endpoint_mixin_form_view
108+
msgid "Purge caches"
109+
msgstr ""
110+
111+
#. module: endpoint_cache
112+
#: model_terms:ir.ui.view,arch_db:endpoint_cache.endpoint_mixin_form_view
113+
msgid "View caches"
114+
msgstr ""
115+
116+
#. module: endpoint_cache
117+
#: model_terms:ir.ui.view,arch_db:endpoint_cache.endpoint_mixin_form_view
118+
msgid ""
119+
"Warning: this might take too long to complete if the endpoint uses expensive "
120+
"computations."
121+
msgstr ""
122+
123+
#. module: endpoint_cache
124+
#: model:ir.model.fields.selection,name:endpoint_cache.selection__endpoint_endpoint__cache_policy__week
125+
#: model:ir.model.fields.selection,name:endpoint_cache.selection__endpoint_mixin__cache_policy__week
126+
msgid "Weekly"
127+
msgstr ""

endpoint_cache/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import endpoint_mixin

0 commit comments

Comments
 (0)