1

我在 ubuntu 12.04 上使用 OpenERP 7。我用“list_db = False”启动了服务器。它工作正常:菜单列表已由输入字段更改。但是当我写一个不退出的数据库名称时,服务器会抛出一个异常而不是显示一条消息:例如“数据库不退出”。这是异常的文本:

Client Traceback (most recent call last):

   File "/opt/openerp/web/addons/web/http.py", line 204, in dispatch
    response["result"] = method(self, **self.params)

   File "/opt/openerp/web/addons/web/controllers/main.py", line 867, in authenticate
    req.session.authenticate(db, login, password, env)

   File "/opt/openerp/web/addons/web/session.py", line 115, in authenticate
    uid = self.proxy('common').authenticate(db, login, password, env)

  File "/opt/openerp/web/addons/web/session.py", line 30, in proxy_method
    result = self.session.send(self.service_name, method, *args)

  File "/opt/openerp/web/addons/web/session.py", line 103, in send
    raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info)

Server Traceback (most recent call last):

  File "/opt/openerp/web/addons/web/session.py", line 89, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)

  File "/opt/openerp/server/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)

  File "/opt/openerp/server/openerp/service/web_services.py", line 433, in dispatch
    return fn(*params)

  File "/opt/openerp/server/openerp/service/web_services.py", line 444, in exp_authenticate
    res_users = pooler.get_pool(db).get('res.users')

  File "/opt/openerp/server/openerp/pooler.py", line 49, in get_pool
    return get_db_and_pool(db_name, force_demo, status, update_module)[1]

  File "/opt/openerp/server/openerp/pooler.py", line 33, in get_db_and_pool
    registry = RegistryManager.get(db_name, force_demo, status, update_module)

  File "/opt/openerp/server/openerp/modules/registry.py", line 192, in get
    update_module)

  File "/opt/openerp/server/openerp/modules/registry.py", line 208, in new
    registry = Registry(db_name)

  File "/opt/openerp/server/openerp/modules/registry.py", line 76, in __init__
    cr = self.db.cursor()

  File "/opt/openerp/server/openerp/sql_db.py", line 484, in cursor
    return Cursor(self._pool, self.dbname, serialized=serialized)

  File "/opt/openerp/server/openerp/sql_db.py", line 182, in __init__
    self._cnx = pool.borrow(dsn(dbname))

  File "/opt/openerp/server/openerp/sql_db.py", line 377, in _locked
    return fun(self, *args, **kwargs)

  File "/opt/openerp/server/openerp/sql_db.py", line 440, in borrow
    result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)

  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in connect
    connection_factory=connection_factory, async=async)

OperationalError: FATAL:  database "db_test" does not exist

编辑:

我刚刚找到了这个错误的原因。请转到“ web/addons/web/static/src/js/chrome.js: line 706:您将看到该on_submit函数有一个“ if”块来验证数据库的字段是否为空。解决方法是添加第二个“ if”块来验证输入的名称是否在数据库列表中在调用do_login(db, login, password)函数之前。

不幸的是,我不知道 JavaScript 编程来解决这个问题

4

1 回答 1

1

为了只显示消息而不是整个异常,您可以将最外层的调用包装在try/except块中:

try:
    <make your call>
except OperationalError, e:
    <evaluate e which is your exception>
于 2013-10-18T16:45:42.527 回答