Browse Source

Merge pull request #9 from huahyong/hyong_patch

[FIX] muk_session_store faulty on redis storage
pull/30/head
Mathias Markl 6 years ago
committed by GitHub
parent
commit
70158d8a76
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      muk_session_store/patch/http.py
  2. 4
      muk_session_store/store/redis.py

8
muk_session_store/patch/http.py

@ -25,8 +25,8 @@ from odoo.http import request
from odoo.tools.func import lazy_property
from odoo.addons.muk_utils.tools.patch import monkey_patch
from odoo.addons.muk_session_store.store import postgres
from odoo.addons.muk_session_store.store import redis
from odoo.addons.muk_session_store.store.postgres import PostgresSessionStore
from odoo.addons.muk_session_store.store.redis import RedisSessionStore
_logger = logging.getLogger(__name__)
@ -79,9 +79,9 @@ class Root(http.Root):
@lazy_property
def session_store(self):
if tools.config.get('session_store_database'):
return postgres.PostgresSessionStore(session_class=http.OpenERPSession)
return PostgresSessionStore(session_class=http.OpenERPSession)
elif tools.config.get('session_store_redis') and redis:
return redis.RedisSessionStore(session_class=http.OpenERPSession)
return RedisSessionStore(session_class=http.OpenERPSession)
return super(Root, self).session_store
http.root = Root()

4
muk_session_store/store/redis.py

@ -59,11 +59,11 @@ class RedisSessionStore(SessionStore):
password=config.get('session_store_pass', None)
)
def _encode_session_key(self, kex):
def _encode_session_key(self, key):
return key.encode('utf-8') if isinstance(key, str) else key
def _get_session_key(self, sid):
return self._encode_session_key(self.key_prefix + sid)
return self._encode_session_key(self.prefix + sid)
@retry_redis
def save(self, session):

Loading…
Cancel
Save