Skip to content

Commit

Permalink
[REV] http: Implicit session deactivation -> Explicit destruction
Browse files Browse the repository at this point in the history
- This commit degrade the performance and introduce a bug for multiple database servers.

This reverts commit bc69b47.
  • Loading branch information
tbe-odoo committed Jan 29, 2018
1 parent af17cd7 commit 6d682ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
8 changes: 1 addition & 7 deletions odoo/addons/base/res/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from odoo.osv import expression
from odoo.service.db import check_super
from odoo.tools import partition
from odoo.http import root

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -373,8 +372,6 @@ def write(self, values):
if any(key.startswith('context_') or key in ('lang', 'tz') for key in values):
self.context_get.clear_cache(self)
if any(key in values for key in ['active'] + USER_PRIVATE_FIELDS):
# force deletion of all sessions for these users
root.session_store.delete_sessions_for_uids(self.ids)
db = self._cr.dbname
for id in self.ids:
self.__uid_cache[db].pop(id, None)
Expand All @@ -388,10 +385,7 @@ def unlink(self):
db = self._cr.dbname
for id in self.ids:
self.__uid_cache[db].pop(id, None)
res = super(Users, self).unlink()
# force deletion of all sessions for these users
root.session_store.delete_sessions_for_uids(self.ids)
return res
return super(Users, self).unlink()

@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
Expand Down
16 changes: 4 additions & 12 deletions odoo/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ def authenticate(self, db, login=None, password=None, uid=None):
self.db = db
self.uid = uid
self.login = login
self.password = password
request.uid = uid
request.disable_db = False

Expand All @@ -1054,6 +1055,7 @@ def check_security(self):
"""
if not self.db or not self.uid:
raise SessionExpiredException("Session expired")
security.check(self.db, self.uid, self.password)

def logout(self, keep_db=False):
for k in self.keys():
Expand All @@ -1066,6 +1068,7 @@ def _default_values(self):
self.setdefault("db", None)
self.setdefault("uid", None)
self.setdefault("login", None)
self.setdefault("password", None)
self.setdefault("context", {})

def get_context(self):
Expand Down Expand Up @@ -1278,17 +1281,6 @@ def start_wrapped(status, headers):
start_response(status, new_headers)
return self.app(environ, start_wrapped)

class OdooSessionStore(werkzeug.contrib.sessions.FilesystemSessionStore):
def delete_sessions_for_uids(self, uids):
# pretty expensive on large session stores, especially non-local!
uids = set(uids)
_logger.info('Deleting all HTTP sessions for UIDs %s', uids)
for sid in self.list():
s = self.get(sid)
if s.uid and s.uid in uids:
_logger.debug('Deleting session %s', sid)
self.delete(s)

class Root(object):
"""Root WSGI application for the OpenERP Web Client.
"""
Expand All @@ -1300,7 +1292,7 @@ def session_store(self):
# Setup http sessions
path = odoo.tools.config.session_dir
_logger.debug('HTTP sessions stored in: %s', path)
return OdooSessionStore(path, session_class=OpenERPSession)
return werkzeug.contrib.sessions.FilesystemSessionStore(path, session_class=OpenERPSession)

@lazy_property
def nodb_routing_map(self):
Expand Down

0 comments on commit 6d682ce

Please sign in to comment.