Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

opcode STORE_FAST not allowed ('lambda') error when Incoming Server's Server Action is set with Python code that is writing to a browse object

By
Ivan
on 8/26/14, 1:50 AM 1,817 views

We are getting opcode STORE_FAST not allowed ('lambda') error when Incoming Server's Server Action is set with Python code that is writing to a browse object.

We are using python version 2.7.3. OpenERP 7.0 server revno 5281.

From what we have tested, if the Server Action does not call any ORM's write method, the action will be executed OK.  But once it call the write method, although if an empty dictionary is passed to the method, the above error message is raised from line 140 of server/openerp/tools/safe_eval.py (where server is the OpenERP's server directory).

Appreciate if anybody can provide insight to this.

0

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 8/26/14, 6:28 AM

Hi Med Said, thank you for your response.  The following is the Python Code we put into the Server Action:

def parse_description(description):
    fields=['name','company','address','phone','mobile','email','message']
    _dict={}
    description=description.lower()
    for line in description.split('\n'):
        for field in fields:
            if field in line:
                split_line=line.split(':')
                if len(split_line)>1:
                    _dict[field]=line.split(':')[1]
    return _dict

lead=self.browse(cr,uid,context['active_id'],context=context)
description=lead['description']
_dict=parse_description(description)
self.write(cr,uid,context['active_id'],{
                        'name':_dict.get('name'),
                        'partner_name':_dict.get('company'),
                        'phone':_dict.get('phone'),
                        'mobile':_dict.get('mobile'),
                        'contact_name':_dict.get('name'),
                        'email_from':_dict.get('email'),
                        'street':_dict.get('address'),
                        'description':_dict.get('message')}, context=context)

We are not sure which part is causing the STORE_FAST opcode.  We have tested to compile the same string under normal python and the dis of the compile code does not list STORE_FAST either.

 

EDIT:

After further testing, we found out that if the code in Python code contains a named method, it raises the said error.  Further reading into the openerp/tools/safe_eval.py file in OpenERP server lines 143 and 144 seems to support the suspicion.  Any way, refactoring the method from the Python Code (making it into normal calls without methods) seems to resolve the issue.

Also it seems that STORE_FAST, along with LOAD_FAST and DELETE_FAST has been listed as allowable opcode since revno 5290 in launchpad or revision 4836354 in github (28 Apr 2014).

 

0

Med Said BARA

--Med Said BARA--
2664
| 5 5 7
Algeria
--Med Said BARA--
Med Said BARA
On 8/26/14, 5:29 AM

Your code is considered as unsafe, probably you've provided a name with two underscore (__name__).

Can you post an example of your code ?

(added after response from John Doe)

The only thing i see in your code that can be related to "dunder" is: _dict=parse_description (maybe putting a space before and after = can resolve this ...).

Another important thing is at line 10: Why are you splitting a second time ? This is done 2 lines above, try to replace with: _dict[field]=split.line[1]

Med Said BARA, Thank you for your further edits. I've also edited by Questions and the problem does not seems to be from names with underscores. Also thank you for the split hint. Yes, we should've use split _dict[field]=line[1] instead.

Ivan
on 8/26/14, 1:03 PM

I will try to test on my side, using your code to see if the error is reproducible.

Med Said BARA
on 8/26/14, 1:38 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 8/26/14, 1:50 AM
Seen: 1817 times
Last updated: 3/16/15, 8:10 AM