Virgil Dupras committed 2c8200f

Added table.Row.*_cell_value() to deal with colname mangling (for reserved keywords clashes).

Comments (0)

Files changed (2)

             return False
         return bool(getattr(prop, 'fset', None))
+    def get_cell_value(self, attrname):
+        if attrname == 'from':
+           attrname = 'from_'
+        return getattr(self, attrname)
+    def set_cell_value(self, attrname, value):
+        if attrname == 'from':
+            attrname = 'from_'
+        setattr(self, attrname, value)


     assert not row.can_edit_cell('foo')
     assert not row.can_edit_cell('baz') # doesn't exist, can't edit
-def test_cen_edit_prop_has_priority_over_fset_checks():
+def test_can_edit_prop_has_priority_over_fset_checks():
     # When a row has a cen_edit_* property, it's the result of that property that is used, not the
     # result of a fset check.
     class TestRow(Row):
     eq_(table.selected_indexes, [6])
+def test_row_cell_value():
+    # *_cell_value() correctly mangles attrnames that are Python reserved words.
+    row = Row(Table())
+    row.from_ = 'foo'
+    eq_(row.get_cell_value('from'), 'foo')
+    row.set_cell_value('from', 'bar')
+    eq_(row.get_cell_value('from'), 'bar')
 def test_sort_table_also_tries_attributes_without_underscores():
     # When determining a sort key, after having unsuccessfully tried the attribute with the,
     # underscore, try the one without one.