def __iter__(self): '''Returns a iterable over the data set''' for k in self.__data__: if isinstance(self.T, KeyHolder) and self.T.cls is not None: yield store.read(k) else: yield k
def __getitem__(self, index): '''Read the item stored at @index, possibly transforming it before returning it''' value = self.__data__[index] if isinstance(self.T, KeyHolder) and self.T.cls is not None: return store.read(value) else: return value
def __getitem__(self, key): '''Validate and possibly transform key before retreival''' key = self.T(key) value = self.__data__[key] if isinstance(self.V, KeyHolder) and self.V.cls is not None: return store.read(value) return value
def __iter__(self): '''Returns a iterable over the data set''' # If we have KeyHolders with Models in them, read the Models and return them. for k in self.__data__: if isinstance(self.T, KeyHolder) and self.T.cls is not None: yield store.read(k) else: yield k