def insert(self, index, item):
""" Insert record to list
:param item: Record instance to be inserted into list.
if int passed, it considered to be ID of record
:type item: Record|int
:param int index: position where to place new element
:return: self
:rtype: RecordList
"""
assert isinstance(item, (Record, numbers.Integral)), \
"Only Record or int instances could be added to list"
if isinstance(item, Record):
self._records.insert(index, item)
else:
self._records.insert(index, self._object.read_records(
item, cache=self._cache))
return self
# Overridden to make ability to call methods of object on list of IDs
# present in this RecordList
评论列表
文章目录