def __init__(self, **kwargs): ''' Construct new Item with attributes kwargs. Raise ItemAttributeError if a required attribute is not found. ''' with_table(self.__class__) self._created = False self._data = {} self._modified = {} self._digest(kwargs)
def resolve(self, index): ''' (Query, int) -> Item Return Item at index based on scope of this Query. ''' # not a hack I promise # makes sure table is created # before querying items with_table(self._table) if self._hash_key: if index != 0: # after setting scope # keys, cannot use index # i.e, this should fail # query.filter(id=_)[1] raise InvalidQueryError(( "Cannot use index " "after having set " "a filtering key." )) return read_item(self)