[7.0] dump/restore cannot get db password from config file
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Server (MOVED TO GITHUB) |
Confirmed
|
Medium
|
OpenERP's Framework R&D |
Bug Description
There is code in lib/python2.
@contextlib
def _set_pg_
""" On Win32, pg_dump (and pg_restore) require that
This context management method handles setting
set, and removing it afterwards.
"""
if os.name != 'nt' or os.environ.
yield
else:
try:
del os.environ[
So, on linux machine it does not read db_password from config, and dump/restore gives you Access Denied. Possible solution is to create .pgpass file, but should not it work just with db_password in config?
Changed in openobject-server: | |
assignee: | nobody → OpenERP's Framework R&D (openerp-dev-framework) |
importance: | Undecided → Medium |
status: | New → Confirmed |
Latest version in trunk (r4854) gives this error when doing a restore:
2013-04-16 04:20:13,258 16812 ERROR None openerp.netsvc: _set_pg_ password_ in_environment( ) takes exactly 1 argument (0 given) openerp7/ trunk/server/ openerp/ netsvc. py", line 237, in dispatch_rpc openerp7/ trunk/server/ openerp/ service/ db.py", line 80, in dispatch openerp7/ trunk/server/ openerp/ service/ db.py", line 253, in exp_restore password_ in_environment( ): python2. 7/contextlib. py", line 84, in helper tManager( func(*args, **kwds)) password_ in_environment( ) takes exactly 1 argument (0 given) addons. web.http: An exception occured during an http request openerp7/ trunk/web/ addons/ web/http. py", line 296, in dispatch openerp7/ trunk/web/ addons/ web/controllers /main.py" , line 818, in restore session. proxy(" db").restore( restore_ pwd, new_db, data) openerp7/ trunk/web/ addons/ web/session. py", line 30, in proxy_method send(self. service_ name, method, *args) openerp7/ trunk/web/ addons/ web/session. py", line 88, in send netsvc. dispatch_ rpc(service_ name, method, args) openerp7/ trunk/server/ openerp/ netsvc. py", line 237, in dispatch_rpc openerp7/ trunk/server/ openerp/ service/ db.py", line 80, in dispatch openerp7/ trunk/server/ openerp/ service/ db.py", line 253, in exp_restore password_ in_environment( ): python2. 7/contextlib. py", line 84, in helper tManager( func(*args, **kwds)) password_ in_environment( ) takes exactly 1 argument (0 given)
Traceback (most recent call last):
File "/home/
result = dispatch(method, params)
File "/home/
return fn(*params)
File "/home/
with _set_pg_
File "/usr/lib/
return GeneratorContex
TypeError: _set_pg_
2013-04-16 04:20:13,259 16812 ERROR None openerp.
Traceback (most recent call last):
File "/home/
r = method(self, **self.params)
File "/home/
req.
File "/home/
result = self.session.
File "/home/
return openerp.
File "/home/
result = dispatch(method, params)
File "/home/
return fn(*params)
File "/home/
with _set_pg_
File "/usr/lib/
return GeneratorContex
TypeError: _set_pg_
After some investigation I found that the contextmanager broke after refactoring, however the following patch might fix this bug (at least I was able to restore databases again):
=== modified file 'openerp/ service/ db.py' service/ db.py 2013-04-04 13:07:04 +0000 service/ db.py 2013-04-16 04:40:40 +0000
--- openerp/
+++ openerp/
@@ -197,7 +197,7 @@
return True
@contextlib. contextmanager password_ in_environment( self): password_ in_environment( self=None) : get('PGPASSWORD ') or not tools.config[ 'db_password' ]: get('PGPASSWORD ') or not openerp. tools.config[ 'db_password' ]: 'PGPASSWORD' ] = tools.config[ 'db_password' ] 'PGPASSWORD' ] = openerp. tools.config[ 'db_password' ]
-def _set_pg_
+def _set_pg_
""" On systems where pg_restore/pg_dump require an explicit
password (i.e. when not connecting via unix sockets, and most
importantly on Windows), it is necessary to pass the PG user
@@ -213,10 +213,10 @@
SaaS (giving SaaS users the super-admin password is not a good idea
anyway)
"""
- if os.environ.
+ if os.environ.
yield
else:
- os.environ[
+ os.environ[
try:
yield
...