28
28
from kiwi.ui.widgets.list import Column
31
class ForeignKeyColumn(Column):
32
"""ForeignKeyColumn is a special column which is normally used together
33
with a foreign key, for an sql table.
35
def __init__(self, table, *args, **kwargs):
36
"""Need an obj_field or adapted argument.
37
See L{kiwi.ui.widgets.list.Column} for other arguments
39
if not 'obj_field' in kwargs and not 'adapted' in kwargs:
41
'ForeigKeyColumn needs an obj_field or adapted argument')
44
self._obj_field = kwargs.pop('obj_field', None)
45
self._adapted = kwargs.pop('adapted', False)
46
Column.__init__(self, *args, **kwargs)
48
def get_attribute(self, instance, name, default=None):
50
value = kgetattr(instance, self._obj_field, default)
57
value = value.get_adapted()
58
return kgetattr(value, name, default)
60
31
class AccessorColumn(Column):
61
32
def __init__(self, attribute, accessor, *args, **kwargs):