本文整理汇总了Python中flaskbb.management.models.Setting.update方法的典型用法代码示例。如果您正苦于以下问题:Python Setting.update方法的具体用法?Python Setting.update怎么用?Python Setting.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flaskbb.management.models.Setting
的用法示例。
在下文中一共展示了Setting.update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from flaskbb.management.models import Setting [as 别名]
# 或者: from flaskbb.management.models.Setting import update [as 别名]
def post(self, slug=None, plugin=None):
form, old_settings, plugin_obj, active_nav = \
self._determine_active_settings(slug, plugin)
all_groups = SettingsGroup.query.all()
all_plugins = PluginRegistry.query.filter(db.and_(
PluginRegistry.values != None,
PluginRegistry.enabled == True
)).all()
if form.validate_on_submit():
new_settings = populate_settings_dict(form, old_settings)
if plugin_obj is not None:
plugin_obj.update_settings(new_settings)
else:
Setting.update(settings=new_settings, app=current_app)
flash(_("Settings saved."), "success")
return render_template(
"management/settings.html",
form=form,
all_groups=all_groups,
all_plugins=all_plugins,
active_nav=active_nav
)
示例2: settings
# 需要导入模块: from flaskbb.management.models import Setting [as 别名]
# 或者: from flaskbb.management.models.Setting import update [as 别名]
def settings(slug=None):
slug = slug if slug else "general"
# get the currently active group
active_group = SettingsGroup.query.filter_by(key=slug).first_or_404()
# get all groups - used to build the navigation
all_groups = SettingsGroup.query.all()
SettingsForm = Setting.get_form(active_group)
old_settings = Setting.get_settings(active_group)
new_settings = {}
form = SettingsForm()
if form.validate_on_submit():
for key, values in iteritems(old_settings):
try:
# check if the value has changed
if values['value'] == form[key].data:
continue
else:
new_settings[key] = form[key].data
except KeyError:
pass
Setting.update(settings=new_settings, app=current_app)
flash(_("Settings saved."), "success")
else:
for key, values in iteritems(old_settings):
try:
form[key].data = values['value']
except (KeyError, ValueError):
pass
return render_template("management/settings.html", form=form,
all_groups=all_groups, active_group=active_group)
示例3: __setitem__
# 需要导入模块: from flaskbb.management.models import Setting [as 别名]
# 或者: from flaskbb.management.models.Setting import update [as 别名]
def __setitem__(self, key, value):
Setting.update({key.lower(): value})