我目前正在为 OpenERP 6.1.1 (python 2.7) 开发一个模块,其中电子邮件通知应由多个工作流状态更改触发。到目前为止,如此明显。当我配置 ir.mail_server 的实例并想要对其进行测试时,我得到以下异常:
Server Traceback (most recent call last):
File "/opt/openerp61/server/openerp/addons/web/common/http.py", line 592, in send
result = openerp.netsvc.dispatch_rpc(service_name, method, args)
File "/opt/openerp61/server/openerp/netsvc.py", line 360, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/opt/openerp61/server/openerp/service/web_services.py", line 572, in dispatch
res = fn(db, uid, *params)
File "/opt/openerp61/server/openerp/osv/osv.py", line 167, in execute_kw
return self.execute(db, uid, obj, method, *args, **kw or {})
File "/opt/openerp61/server/openerp/osv/osv.py", line 121, in wrapper
return f(self, dbname, *args, **kwargs)
File "/opt/openerp61/server/openerp/osv/osv.py", line 176, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/opt/openerp61/server/openerp/osv/osv.py", line 164, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/opt/openerp61/server/openerp/addons/base/ir/ir_mail_server.py", line 191, in test_smtp_connection
smtp_debug=smtp_server.smtp_debug)
File "/opt/openerp61/server/openerp/addons/base/ir/ir_mail_server.py", line 241, in connect
connection.login(user, password)
File "/usr/lib/python2.7/smtplib.py", line 598, in login
(code, resp) = self.docmd(encode_cram_md5(resp, user, password))
File "/usr/lib/python2.7/smtplib.py", line 562, in encode_cram_md5
response = user + " " + hmac.HMAC(password, challenge).hexdigest()
File "/usr/lib/python2.7/hmac.py", line 72, in __init__
self.outer.update(key.translate(trans_5C))
TypeError: character mapping must return integer, None or unicode
问题似乎很明显,因为传递给 smtplib.SMTP.login() 的用户和密码参数是 unicode 编码的,这是 HMAC 不喜欢的。如果我“修复” OpenERP 核心并将这些参数转换为字符串,一切似乎都可以正常工作。至少 ir.mail_server 的“测试连接”功能是这样说的。
当我在这个项目中学习 OpenERP 和 Python 时,我不知道如何继续,因为几乎没有任何人提到过这个问题。因此,我的猜测是我的开发设置有一些“错误”触发了这个问题。我可以把核心补丁留在那里继续开发,但这不是一个真正的选择,因为这可能有一天会回来并咬我的屁股。
对此的任何输入都会很棒。