def load(self): usr = self.request.current_user level_u = UserSettingHelper(usr) level_u_ = level_u.load() level_s = AppSettingHelper.load() level_all = dict(level_u_, **level_s) return level_all
def save(self): kv = self.request.wrap_params_to_dict() level_user = dict() level_system = dict() for k in kv: if k.startswith("u_"): level_user[k] = kv[k] elif k.startswith("s_"): level_system[k] = kv[k] AppSettingHelper.set(level_system) u = UserSettingHelper("%s" % self.request.current_user) u.set(level_user) #允许用户在设置保存之后再做其它数据变更 items = ObjectPool.setting for k in items.keys(): obj = items[k].cls() if hasattr(obj, "save"): msg = obj.save(kv, self.request) if msg: return msg AppSettingHelper.reload() return "success"