def create_index(self, index_name, public_search=None): index = Index() # basic index data index.populate_for_account(self) index.name = index_name index.creation_time = datetime.now() index.language_code = 'en' index.status = Index.States.new if not public_search is None: index.public_api = public_search # test for name uniqueness # raises IntegrityError if the index name already exists index.save() # define the default function function = ScoreFunction() function.index = index function.name = '0' function.definition = '-age' function.save() # deduce code from id index.code = encoder.to_key(index.id) index.save() return index
def create_index(self, index_name, public_search=None): index = Index() # basic index data index.populate_for_account(self) index.name = index_name index.creation_time = datetime.now() index.language_code = "en" index.status = Index.States.new if not public_search is None: index.public_api = public_search # test for name uniqueness # raises IntegrityError if the index name already exists index.save() # define the default function function = ScoreFunction() function.index = index function.name = "0" function.definition = "-age" function.save() # deduce code from id index.code = encoder.to_key(index.id) index.save() return index
def generate_forgotpass(id): key = settings.FORGOTPASS_KEY while True: hash = hashlib.md5() hash.update("%d" % id) hash.update(key) hash.update("%d" % random.randint(0, sys.maxint)) random_part = binascii.b2a_base64(hash.digest())[:6] if not "/" in random_part: break unique_part = encoder.to_key(id) return random_part + unique_part
def generate_apikey(id): key = settings.APIKEY_KEY while True: hash = hashlib.md5() hash.update("%d" % id) hash.update(key) hash.update("%d" % random.randint(0, sys.maxint)) random_part = binascii.b2a_base64(hash.digest())[:14] if not "/" in random_part: break unique_part = encoder.to_key(id) return unique_part + "-" + random_part
def generate_forgotpass(id): key = settings.FORGOTPASS_KEY while True: hash = hashlib.md5() hash.update('%d' % id) hash.update(key) hash.update('%d' % random.randint(0, sys.maxint)) random_part = binascii.b2a_base64(hash.digest())[:6] if not '/' in random_part: break unique_part = encoder.to_key(id) return random_part + unique_part
def generate_apikey(id): key = settings.APIKEY_KEY while True: hash = hashlib.md5() hash.update('%d' % id) hash.update(key) hash.update('%d' % random.randint(0, sys.maxint)) random_part = binascii.b2a_base64(hash.digest())[:14] if not '/' in random_part: break unique_part = encoder.to_key(id) return unique_part + '-' + random_part
def generate_forgotpass(id): key = "E57024920CE4B0CE4643CAEFAC47D6F7D7270CDA6CF03D254C1C29402A1A8AE7" while True: hash = hashlib.md5() hash.update('%d' % id) hash.update(key) hash.update('%d' % random.randint(0, 1000000)) random_part = binascii.b2a_base64(hash.digest())[:6] if not '/' in random_part: break unique_part = encoder.to_key(id) return random_part + unique_part
def generate_apikey(id): key = "2A1A8AE7CAEFAC47D6F74920CE4B0CE46430CDA6CF03D254C1C29402D727E570" while True: hash = hashlib.md5() hash.update('%d' % id) hash.update(key) hash.update('%d' % random.randint(0, 1000000)) random_part = binascii.b2a_base64(hash.digest())[:14] if not '/' in random_part: break unique_part = encoder.to_key(id) return unique_part + '-' + random_part
def generate_forgotpass(id): key = "E57024920CE4B0CE4643CAEFAC47D6F7D7270CDA6CF03D254C1C29402A1A8AE7" while True: hash = hashlib.md5() hash.update('%d' % id) hash.update(key) hash.update('%d' % random.randint(0,1000000)) random_part = binascii.b2a_base64(hash.digest())[:6] if not '/' in random_part: break unique_part = encoder.to_key(id) return random_part + unique_part
def generate_apikey(id): key = "2A1A8AE7CAEFAC47D6F74920CE4B0CE46430CDA6CF03D254C1C29402D727E570" while True: hash = hashlib.md5() hash.update('%d' % id) hash.update(key) hash.update('%d' % random.randint(0,1000000)) random_part = binascii.b2a_base64(hash.digest())[:14] if not '/' in random_part: break unique_part = encoder.to_key(id) return unique_part + '-' + random_part
def get_index_code(id): return encoder.to_key(id)