Beispiel #1
0
 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
Beispiel #2
0
 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
Beispiel #3
0
 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
Beispiel #4
0
 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