Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
df40a05
session_db : store sessions in a database rather than in filestore
nseinlet Oct 3, 2017
a1d181d
[MIG] session_db to 16.0
sbidoul Oct 29, 2022
da5e10c
session_db: use SESSION_LIFETIME constant
sbidoul Oct 29, 2022
b6576c7
session_db: do not update write_date on get
sbidoul Oct 29, 2022
48cc284
session_db: declare maintainer
sbidoul Oct 29, 2022
e6f3b31
session_db: explain why such as module is useful
sbidoul Jan 17, 2023
767a66e
[UPD] Update session_db.pot
Jan 19, 2023
fa8b66a
[UPD] README.rst
OCA-git-bot Jan 19, 2023
220af70
[ADD] icon.png
OCA-git-bot Jan 19, 2023
c2300cd
session_db 16.0.1.0.1
OCA-git-bot Jan 19, 2023
f1826b4
session_db: improve resiliency to database errors
sbidoul Jan 21, 2023
e968de1
session_db 16.0.1.0.2
OCA-git-bot Jan 23, 2023
113109d
session_db: gevent and thread support
sbidoul Feb 10, 2023
cd49ea7
session_db: cosmetics
sbidoul Feb 10, 2023
133c6a6
session_db: improve cursor release
sbidoul Feb 10, 2023
55ac1c0
session_db 16.0.1.0.3
OCA-git-bot Feb 21, 2023
b5d9557
session_db: reconnect if needed
sbidoul Mar 23, 2023
e7f1845
session_db: add a few tests
sbidoul Mar 23, 2023
fe76584
session_db: refactor retry handling
sbidoul Mar 24, 2023
9a0ee64
session_db: fix tests for v16 compatibility
sbidoul Mar 27, 2023
68ef3e0
session_db 16.0.1.0.4
OCA-git-bot Apr 11, 2023
040c520
Fixes the issue "PGSessionStore.vacuum() got an unexpected keyword ar…
Aug 16, 2023
564af55
session_db 16.0.1.0.5
OCA-git-bot Sep 1, 2023
dc5d5ce
[UPD] README.rst
OCA-git-bot Sep 3, 2023
c143bf9
[IMP] session_db: pre-commit auto fixes
sbidoul Nov 12, 2023
2381797
[MIG] session_db: from 16.0 to 17.0
sbidoul Nov 12, 2023
ca9cae6
[IMP] session_db: remove roadmap
sbidoul Jul 22, 2024
4c48f0e
[UPD] Update session_db.pot
Sep 17, 2024
304b90f
[BOT] post-merge updates
OCA-git-bot Sep 17, 2024
c27b5b2
Added translation using Weblate (Italian)
mymage Oct 4, 2024
7386e46
[IMP] session_db: pre-commit auto fixes
sbidoul Oct 7, 2024
e064766
[MIG] session_db: migration to 18.0 from 17.0
sbidoul Oct 7, 2024
c1b0957
[UPD] Update session_db.pot
Nov 13, 2024
5500446
[BOT] post-merge updates
OCA-git-bot Nov 13, 2024
e6f38eb
Update translation files
weblate Nov 13, 2024
18c78ea
[PATCH] [FIX] session_db: Fix creation of postgres_uri in tests
lal-solute Feb 3, 2025
28562b1
[BOT] post-merge updates
OCA-git-bot Feb 7, 2025
cfd8b04
[MIG] session_db: Migration to 19.0
FrancoMaxime Oct 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions session_db/README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

====================
Store sessions in DB
====================
Expand All @@ -13,17 +17,17 @@ Store sessions in DB
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/18.0/session_db
:target: https://github.com/OCA/server-tools/tree/19.0/session_db
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-session_db
:target: https://translation.odoo-community.org/projects/server-tools-19-0/server-tools-19-0-session_db
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=18.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -54,7 +58,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20session_db%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20session_db%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -88,6 +92,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-sbidoul|

This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/18.0/session_db>`_ project on GitHub.
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/19.0/session_db>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion session_db/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Store sessions in DB",
"version": "18.0.1.0.1",
"version": "19.0.1.0.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FrancoMaxime The better is to reset to 19.0.1.0.0

"author": "Odoo SA,ACSONE SA/NV,Odoo Community Association (OCA)",
"license": "LGPL-3",
"website": "https://github.com/OCA/server-tools",
Expand Down
4 changes: 2 additions & 2 deletions session_db/pg_session_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# @author Nicolas Seinlet
# Copyright (c) ACSONE SA 2022
# @author Stéphane Bidoul
import functools
import json
import logging
import os
Expand All @@ -11,7 +12,6 @@
import odoo
from odoo import http
from odoo.tools._vendor import sessions
from odoo.tools.func import lazy_property

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -153,7 +153,7 @@ def vacuum(self, max_lifetime=http.SESSION_LIFETIME):
_original_session_store = http.root.__class__.session_store


@lazy_property
@functools.cached_property
def session_store(self):
session_db_uri = os.environ.get("SESSION_DB_URI")
if session_db_uri:
Expand Down
28 changes: 17 additions & 11 deletions session_db/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Store sessions in DB</title>
<title>README.rst</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,16 +360,21 @@
</style>
</head>
<body>
<div class="document" id="store-sessions-in-db">
<h1 class="title">Store sessions in DB</h1>
<div class="document">


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="store-sessions-in-db">
<h1>Store sessions in DB</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7558240596b423e92065ebf70859ac382972bca78db62368b1d0e7f06cc2a266
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-tools/tree/18.0/session_db"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-session_db"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-tools&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-tools/tree/19.0/session_db"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-tools-19-0/server-tools-19-0-session_db"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-tools&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Store sessions in a database instead of the filesystem. This simplifies
the configuration of horizontally scalable deployments, by avoiding the
need for a distributed filesystem to store the Odoo sessions.</p>
Expand All @@ -386,32 +391,32 @@ <h1 class="title">Store sessions in DB</h1>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
<p>Set this module in the server wide modules.</p>
<p>Set a <tt class="docutils literal">SESSION_DB_URI</tt> environment variable as a full postgresql
connection string, like <tt class="docutils literal"><span class="pre">postgres://user:passwd&#64;server/db</span></tt> or <tt class="docutils literal">db</tt>.</p>
<p>It is recommended to use a dedicated database for this module, and
possibly a dedicated postgres user for additional security.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20session_db%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20session_db%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
<ul class="simple">
<li>Odoo SA</li>
<li>ACSONE SA/NV</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -421,10 +426,11 @@ <h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/sbidoul"><img alt="sbidoul" src="https://github.com/sbidoul.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/18.0/session_db">OCA/server-tools</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/19.0/session_db">OCA/server-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</div>
</body>
</html>
5 changes: 4 additions & 1 deletion session_db/tests/test_pg_session_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def _make_postgres_uri(
class TestPGSessionStore(TransactionCase):
def setUp(self):
super().setUp()
_, connection_info = connection_info_for(config["db_name"])
db_name = config["db_name"]
if isinstance(db_name, list):
db_name = db_name[0]
_, connection_info = connection_info_for(db_name)
self.session_store = PGSessionStore(
_make_postgres_uri(**connection_info), session_class=http.Session
)
Expand Down