def hashid(self): # A unique identifier for the form that maps to its id, # but doesn't seem like a sequential integer try: return self._hashid except AttributeError: if not self.id: raise Exception("this form doesn't have an id yet, commit it first.") self._hashid = HASHIDS_CODEC.encode(self.id) return self._hashid
def get_with_hashid(cls, hashid): id = HASHIDS_CODEC.decode(hashid)[0] return cls.query.get(id)
def get_with_hashid(cls, hashid): try: id = HASHIDS_CODEC.decode(hashid)[0] return cls.query.get(id) except IndexError: return None
def get_form_by_random_like_string(cls, random_like_string): id = HASHIDS_CODEC.decode(random_like_string)[0] return cls.query.get(id)
def get_random_like_string(self): if not self.id: raise Exception( "this form doesn't have an id yet, commit it first.") return HASHIDS_CODEC.encode(self.id)
def get_random_like_string(self): if not self.id: raise Exception("this form doesn't have an id yet, commit it first.") return HASHIDS_CODEC.encode(self.id)