← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 487251] Re: _ translate function blows up if used in method with a parameter named 'args': AttributeError: 'list' object has no attribute 'get' in lang = args[-1].get('lang', False)

 

** Changed in: openobject-server
     Assignee: Anup (OpenERP) (ach-openerp) => OpenERP's Framework R&D (openerp-dev-framework)

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/487251

Title:
  _ translate function blows up if used in method with a parameter named 'args': AttributeError: 'list' object has no attribute 'get'  in lang = args[-1].get('lang',False)

Status in OpenObject Server:
  In Progress

Bug description:
  Hello,

since some 1 week and 3 weeks at the very max, when using openerp-server 5.0 head revisions, I have this error when I try to connect me to the server:

No LSB modules are available.
[2009-11-23 20:19:35,840] ERROR:web-services:[01]: 
[2009-11-23 20:19:35,840] ERROR:web-services:[02]: Environment Information : 
[2009-11-23 20:19:35,840] ERROR:web-services:[03]: System : Linux-2.6.28-11-server-x86_64-with-Ubuntu-9.04-jaunty
[2009-11-23 20:19:35,840] ERROR:web-services:[04]: OS Name : posix
[2009-11-23 20:19:35,840] ERROR:web-services:[05]: Distributor ID:	Ubuntu
[2009-11-23 20:19:35,841] ERROR:web-services:[06]: Description:	Ubuntu 9.04
[2009-11-23 20:19:35,841] ERROR:web-services:[07]: Release:	9.04
[2009-11-23 20:19:35,841] ERROR:web-services:[08]: Codename:	jaunty
[2009-11-23 20:19:35,841] ERROR:web-services:[09]: Operating System Release : 2.6.28-11-server
[2009-11-23 20:19:35,841] ERROR:web-services:[10]: Operating System Version : #42-Ubuntu SMP Fri Apr 17 02:45:36 UTC 2009
[2009-11-23 20:19:35,841] ERROR:web-services:[11]: Operating System Architecture : 64bit
[2009-11-23 20:19:35,841] ERROR:web-services:[12]: Operating System Locale : en_US.UTF8
[2009-11-23 20:19:35,841] ERROR:web-services:[13]: Python Version : 2.6.2
[2009-11-23 20:19:35,841] ERROR:web-services:[14]: OpenERP-Server Version : 5.0.6
[2009-11-23 20:19:35,842] ERROR:web-services:[15]: Last revision No. & ID : 1878 jvo@xxxxxxxxxxx-20091123122736-591bz55oke4ot5mj
[2009-11-23 20:19:35,842] ERROR:web-services:[16]: 
[2009-11-23 20:19:35,842] ERROR:web-services:[17]: Traceback (most recent call last):
[2009-11-23 20:19:35,842] ERROR:web-services:[18]:   File "/opt/openerp5.0_test/server/bin/osv/osv.py", line 61, in wrapper
[2009-11-23 20:19:35,842] ERROR:web-services:[19]:     return f(self, dbname, *args, **kwargs)
[2009-11-23 20:19:35,842] ERROR:web-services:[20]:   File "/opt/openerp5.0_test/server/bin/osv/osv.py", line 120, in execute
[2009-11-23 20:19:35,842] ERROR:web-services:[21]:     res = pool.execute_cr(cr, uid, obj, method, *args, **kw)
[2009-11-23 20:19:35,842] ERROR:web-services:[22]:   File "/opt/openerp5.0_test/server/bin/osv/osv.py", line 112, in execute_cr
[2009-11-23 20:19:35,843] ERROR:web-services:[23]:     return getattr(object, method)(cr, uid, *args, **kw)
[2009-11-23 20:19:35,843] ERROR:web-services:[24]:   File "/opt/openerp5.0_test/addons/magentoerpconnect/magerp_core.py", line 56, in core_sync
[2009-11-23 20:19:35,843] ERROR:web-services:[25]:     self.pool.get('external.shop.group').mage_import_base(cr, uid,core_imp_conn, inst.id, defaults={'referential_id':inst.id})
[2009-11-23 20:19:35,843] ERROR:web-services:[26]:   File "/opt/openerp5.0_test/addons/magentoerpconnect/magerp_osv.py", line 246, in mage_import_base
[2009-11-23 20:19:35,843] ERROR:web-services:[27]:     data = conn.call(list_method, context['ids_or_filter'])
[2009-11-23 20:19:35,843] ERROR:web-services:[28]:   File "/opt/openerp5.0_test/addons/magentoerpconnect/magerp_osv.py", line 74, in call
[2009-11-23 20:19:35,843] ERROR:web-services:[29]:     self.logger.notifyChannel(_("Magento Call"), netsvc.LOG_WARNING, _("Webservice Failure, sleeping 1 second before next attempt"))
[2009-11-23 20:19:35,843] ERROR:web-services:[30]:   File "/opt/openerp5.0_test/server/bin/tools/translate.py", line 139, in __call__
[2009-11-23 20:19:35,843] ERROR:web-services:[31]:     lang = args[-1].get('lang',False)
[2009-11-23 20:19:35,844] ERROR:web-services:[32]: AttributeError: 'list' object has no attribute 'get'



I use to make it start and see no bug with the following patch:

=== modified file 'bin/tools/translate.py'
--- bin/tools/translate.py	2009-11-17 12:45:11 +0000
+++ bin/tools/translate.py	2009-11-18 14:21:07 +0000
@@ -135,7 +135,7 @@
         
         if not (cr and lang):
             args = frame.f_locals.get('args',False)
-            if args:
+            if args and type(args[-1]) == dict:
                 lang = args[-1].get('lang',False)
                 if frame.f_globals.get('pooler',False):
                     cr = pooler.get_db(frame.f_globals['pooler'].pool_dic.keys()[0]).cursor()


HOWEVER, I MIGHT NOT HAVE TESTED ALL THE FEATURES AND CONSIDER THAT A UGLY WORKAROUND. SO PLEASE DON'T JUST COMMIT THAT PATCH WITHOUT FINDING THE REAL BUG CAUSE/REAL SOLUTION.

Hope this helps