When a view has an invalid attrs Koo raises an "TypeError: globals must be a dict" instead

Bug #562923 reported by Borja López Soilán (NeoPolus)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KDE OpenObject Client
New
Undecided
Unassigned

Bug Description

When a view has a field with an invalid attrs tag, a stacktrace like this is shown:

---
  File "/usr/local/lib/python2.6/dist-packages/Koo/Model/Record.py", line 173, in updateAttributes
    attributeChanges = eval( attributes, self.value( fieldName ) )
TypeError: globals must be a dict
---

This exception should be shown instead:

---
  File "/usr/local/lib/python2.6/dist-packages/Koo/Model/Record.py", line 173, in updateAttributes
    attributeChanges = eval( attributes, { fieldName: self.value( fieldName ) } )
  File "<string>", line 1
    {'readonly':[('milestone','=',True])}
                                      ^
SyntaxError: invalid syntax
---

The problem is that if the evaluation of the attrs fails, then Koo retries it passing the value of the field as a parameter to the eval function. This is not correct! A dict should be passed instead to eval!

Currently:
---
   try:
    attributeChanges = eval( attributes )
   except:
    attributeChanges = eval( attributes, self.value( fieldName ) )
---

Should be:
---
   try:
    attributeChanges = eval( attributes )
   except:
    attributeChanges = eval( attributes, { fieldName: self.value( fieldName ) } )
---

(Note: I noticed this bug while working on invalid bug 562881)

Revision history for this message
Borja López Soilán (NeoPolus) (borjals) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.