[IMP]Odoo Auth plugin : make Odoo as class object, for reuse elsewhere (on storage)
This commit is contained in:
parent
94f6e12601
commit
b92e8c3508
@ -26,12 +26,14 @@ from radicale.auth import BaseAuth
|
||||
class Auth(BaseAuth):
|
||||
""" BaseAuth implementation for Odoo Radicale Authentication """
|
||||
|
||||
odoo = False
|
||||
|
||||
def __init__(self, configuration, logger):
|
||||
super(Auth, self).__init__(configuration, logger)
|
||||
host = self.configuration.get('auth', 'odoo_host', fallback='127.0.0.1')
|
||||
port = self.configuration.get('auth', 'odoo_port', fallback=8069)
|
||||
try:
|
||||
self.odoo = ODOO(host, port=port)
|
||||
self.__class__.odoo = ODOO(host, port=port)
|
||||
except RPCError as rpcerr:
|
||||
self.logger.error(rpcerr)
|
||||
raise RuntimeError(rpcerr)
|
||||
@ -44,7 +46,7 @@ class Auth(BaseAuth):
|
||||
if not user or not password:
|
||||
return False
|
||||
try:
|
||||
self.odoo.login(database, user, password)
|
||||
self.__class__.odoo.login(database, user, password)
|
||||
self.logger.info('Login successfull for {} on database {}'.format(user, database))
|
||||
return True
|
||||
except RPCError as rpcerr:
|
||||
|
Loading…
Reference in New Issue
Block a user