Comment 5 for bug 487251

Revision history for this message
Xavier Fernandez http://www.smile.fr (xav-fernandez) wrote : Re: 5.0 regression: AttributeError: 'list' object has no attribute 'get' in lang = args[-1].get('lang',False)

Hello,

this problem occurs every time you use the _() function from translate (from tools.translate import _) in a function containing an argument or local variable named 'args'.

args = frame.f_locals.get('args',False) checks if this variable (or agument) exists and if it does, it expects it to be a list (or dictionnary with "-1" key) which last item is a dictionnary (args[-1].get('lang',False))

In the OpenERP-magento connector: def call(self, method, *args):
this is not infortunatly not the case.

I had the same issue for a custom development.
Most of my webservices expected an args argument (def create_booking(self, cr, uid, args, context={}):)

A easy solution is to rename the 'args' argument into something else (like arguments or args2 or whatever_feels_right). Same goes for local variables.

But I think the _() should also be improved in order to deal with 'args' local variables that are not list which last item is a dictionnary...