Example #1
0
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}
Example #2
0
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
    }
Example #3
0
 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)
Example #4
0
 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)