add utility property and function for accessing data table data as records/rows
This commit is contained in:
parent
beff6ef2dd
commit
c4ce28e239
2 changed files with 9 additions and 0 deletions
|
@ -913,6 +913,12 @@ relates ISO country codes with the full name of the country.
|
|||
>>> sorted(adapted(concepts['countries']).data.items())
|
||||
[('at', ['Austria']), ('de', ['Germany'])]
|
||||
|
||||
>>> countries.dataAsRecords
|
||||
[{'value': 'Austria', 'key': 'at'}, {'value': 'Germany', 'key': 'de'}]
|
||||
|
||||
>>> countries.getRowsByValue('value', 'Germany')
|
||||
[{'value': 'Germany', 'key': 'de'}]
|
||||
|
||||
|
||||
Caching
|
||||
=======
|
||||
|
|
3
table.py
3
table.py
|
@ -106,6 +106,9 @@ class DataTable(AdapterBase):
|
|||
result.append(item)
|
||||
return result
|
||||
|
||||
def getRowsByValue(self, column, value):
|
||||
return [r for r in self.dataAsRecords if r[column] == value]
|
||||
|
||||
|
||||
TypeInterfaceSourceList.typeInterfaces += (IDataTable,)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue