def generate(request): try: char_count = int(request.params.get('char_count', DEFAULT_CHAR_COUNT)) except ValueError: char_count = DEFAULT_CHAR_COUNT try: pseudo_random_id = base28.genbase(char_count) except: raise httpexceptions.HTTPBadRequest() return {'generated_id': pseudo_random_id, 'default_char_count': DEFAULT_CHAR_COUNT, 'char_count': char_count}
def generate(request): try: char_count = int(request.params.get('char_count', DEFAULT_CHAR_COUNT)) except ValueError: char_count = DEFAULT_CHAR_COUNT try: pseudo_random_id = base28.genbase(char_count) except: raise httpexceptions.HTTPBadRequest() return { 'generated_id': pseudo_random_id, 'default_char_count': DEFAULT_CHAR_COUNT, 'char_count': char_count }
def get_aid(self): """ Produce a fresh `aid` only for instances not yet persisted. """ return self.aid if (self.id and self.aid) else genbase(10)