def neck(self): try: return diacore.get_traits(user_pk=self.user_pk, kind=TraitKind.NECK_PERIMETER_CM, order_ascending=False, limit=1)[0] except IndexError: return None
def weight(self): try: return diacore.get_traits(user_pk=self.user_pk, kind=TraitKind.WEIGHT_KG, order_ascending=False, limit=1)[0] except IndexError: return None
def sex(self): try: return diacore.get_traits(user_pk=self.user_pk, kind=TraitKind.SEX, order_ascending=False, limit=1)[0] except IndexError: return None
def age(self): try: birth_utc_timestamp = diacore.get_traits( user_pk=self.user_pk, kind=TraitKind.BIRTH_UTC_TIMESTAMP, order_ascending=False, limit=1)[0] except IndexError: return None timedelta = self.current_datetime - Datetime.utcfromtimestamp( birth_utc_timestamp) return timedelta.total_years
from dia.core import diacore from dia.models import Trait, TraitKind print diacore.get_traits(1, kind=TraitKind.HEIGHT_CM, limit=1)[0]