def set_cach(key, data): if find_one('cach', {'_id': key}): update('cach', {'_id': key}, data) else: data['_id'] = key insert('cach', data)
def vertify_user(uid, password, collection='users' ,vertify_code = '' ): user = find_one(collection, {'_id': uid}) if user: if user.get('password', '') == password: return user else: return False else: return False
def update_loc(user): area_id = user.get('area_id', None) user.update( { 'province': find_one("city", {"_id": user.get('province_id')}).get("city_name") } ) user.update( { 'city': find_one("city", {"_id": user.get('city_id')}).get("city_name") } ) if area_id: user.update( { 'area': find_one("city", {"_id": area_id}).get("city_name", '') } ) return user
def is_converd(entry_list): """ @todo: 判断单个任务数据多媒体数据是否被转码 @param entry_list: 任务数据 """ if not has_media(entry_list): return False for field in entry_list: if has_media_field(field): if not find_one("fs.files", {"uuid": field.get("uuid"), "converd": True}): return False return True
def test_convert_media(self): try: result = convert_media() except: from lib.utils import print_err print_err() print "convert " print result self.assertTrue(result) update_task_data_media() result = find_one("TaskData", {"_id": self.task_id}) self.assertTrue(result.get("converd", False)) self.assertTrue(result.get("entryList")[0].get("converdid", False))
def is_converd(entry_list): """ @todo: 判断单个任务数据多媒体数据是否被转码 @param entry_list: 任务数据 """ if not has_media(entry_list): return False for field in entry_list: if has_media_field(field): if not find_one("fs.files", { "uuid": field.get("uuid"), "converd": True }): return False return True
def test_convert_media(self): try: result = convert_media() except: from lib.utils import print_err print_err() print "convert " print result self.assertTrue(result) update_task_data_media() result = find_one("TaskData", { "_id": self.task_id } ) self.assertTrue(result.get("converd", False)) self.assertTrue(result.get("entryList")[0].get("converdid", False))
def get_cach(key): return find_one('cach', {'_id': key})
def test_update_info(self): update_info('users', {'_id': 'test_update'}, {'city': 'hongkong'}) self.assertEqual( 'hongkong', find_one('users', {'_id': 'test_update'}).get('city', '') )
def update_user(_id, info): info = update_loc(info) update('users', {'_id': _id}, info) return find_one("users", {"_id": _id})
def check_only_user(_id): if find_one('users', {'_id': _id}): return False else: return True
def get_converd_id(uuid): """ @todo: 通过UUID获取文件 @param uuid: uuid """ return find_one("fs.files", {"uuid": uuid}).get("converdid")
def get_city_by_id(id): return find_one('city', {'_id': id})
def get_one_info(collection, query={}): return find_one(collection, query=query);