예제 #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}
예제 #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
    }
예제 #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)
예제 #4
0
파일: models.py 프로젝트: jamilatta/balaio
 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)