Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
We are running odoo on two dedicated servers with the same database. A load balancer distribute the requests to both servers. The problem is that both servers don't know the user sessions of each other server because the sessions are saved on the filesystem (werkzeug.contrib.sessions.FilesystemSessionStore, see openerp/http.py -> Root -> session_store). So I thought I overwrite this session with an own postgres session store by a new module (which I want to contribute if it's done).
Ok, this is the theory and it works - at least if the module is already installed and the database is known at the start of odoo (e.g. with -d <database>). The problem is that the module file is only loaded if the module is installed (what is good). But if this file is loaded to late then other functions have already fetched the session store. So my overwritings are too late.
Here is an minimized example of my module:
from openerp.http import OpenERPSession, Root
from openerp.tools.func import lazy_property
from werkzeug.contrib.sessions import SessionStore
# some functions which are already implemented
Root.session_store = session_store
Now is my question: Do you know a better way to replace the session store without overwriting the odoo core so that the session store is replaced if the module is installed later or database is given later? I thought about some hacks like in  but I think this is not the good way.
In Odoo this can be implemented as a command and used to run Odoo with the needed calls to the bootstrap code and changes to http.py before been loaded because for commands the modules are loaded ok. The default command is server who bootstrap the Odoo server using the config options. Your command need to do pretty much the same but with changes in the right places
I have two suggestions
1 - Why not use nfs to share session_dir?
2 - Implement a custom start script instead of odoo.py and reassign openerp.http.root to your override.
return <your session store instance>
Then in your main method
openerp.http.root = NewRoot() #override here
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 6/16/15, 10:46 AM|
|Seen: 3368 times|
|Last updated: 5/15/16, 10:18 PM|