Пример #1
0
 def get_value(self, ids=False):
   # all models are converted to IDs (aggregation routines yield IDs, so scalar meta return IDs for consistency)
   return simplify_tuple(tuple((model_to_id if ids else (lambda _:_))(getattr(self, f, None)) for f in self._value_fields()))
Пример #2
0
 def _value_map(self, value, reverse=False):
   if reverse:
     return simplify_tuple(tuple(value[f] for f in self._value_fields()))
   
   return dict(itertools.izip(self._value_fields(), ensure_tuple(value)))