def update_userprop(p_key, p_value, user_id, modifier_id): if strutil.is_empty(p_key): raise CoreError("the prop key can't be empty.") query = UserProp.all() query.filter("p_key =", p_key) query.filter("user_id =", user_id) if get_userprop(p_key, user_id) == None: raise CoreError("the prop key %s of user %d doesn't exist." % (p_key, user_id)) else: userprop = query.get() userprop.p_key = p_key p_value = strutil.to_str(p_value) userprop.p_value = p_value userprop.update(modifier_id)
def create_userprop(p_key, p_value, user_id, modifier_id): if strutil.is_empty(p_key): raise CoreError("user prop key can't be empty.") query = UserProp.all() query.filter("p_key =", p_key) query.filter("user_id =", user_id) if query.count() > 0: raise CoreError("the prop key %s of the user %d has existed." % (p_key, user_id)) userprop = UserProp() userprop.p_key = p_key p_value = strutil.to_str(p_value) userprop.p_value = p_value userprop.user_id = user_id userprop.create(modifier_id) return userprop