pytask/utils.py
author Nishanth Amuluru <nishanth@fossee.in>
Sat, 08 Jan 2011 11:20:57 +0530
changeset 69 c6bca38c1cbf
parent 15 utils.py@beb830b0e744
permissions -rw-r--r--
Added buildout stuff and made changes accordingly

import string,random

def make_key(model_name):
    """ return a 10 character random key.
    """

    while True:
        key = ''.join([ random.choice(string.uppercase+string.digits) for i in range(10)])
        try:
            model_name.objects.get(uniq_key=key)
        except model_name.DoesNotExist:
            return key