Example #1
0
 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
Example #2
0
 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
Example #3
0
 def get_with_hashid(cls, hashid):
     id = HASHIDS_CODEC.decode(hashid)[0]
     return cls.query.get(id)
Example #4
0
 def get_with_hashid(cls, hashid):
     try:
         id = HASHIDS_CODEC.decode(hashid)[0]
         return cls.query.get(id)
     except IndexError:
         return None
Example #5
0
 def get_with_hashid(cls, hashid):
     try:
         id = HASHIDS_CODEC.decode(hashid)[0]
         return cls.query.get(id)
     except IndexError:
         return None
Example #6
0
 def get_form_by_random_like_string(cls, random_like_string):
     id = HASHIDS_CODEC.decode(random_like_string)[0]
     return cls.query.get(id)
Example #7
0
 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)
Example #8
0
 def get_with_hashid(cls, hashid):
     id = HASHIDS_CODEC.decode(hashid)[0]
     return cls.query.get(id)
Example #9
0
 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)