本文整理汇总了Python中bottle.ConfigDict.update方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigDict.update方法的具体用法?Python ConfigDict.update怎么用?Python ConfigDict.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bottle.ConfigDict
的用法示例。
在下文中一共展示了ConfigDict.update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: config_page
# 需要导入模块: from bottle import ConfigDict [as 别名]
# 或者: from bottle.ConfigDict import update [as 别名]
def config_page():
"""
Display general configuration.
Display specific static weblog engine configuration.
Allow to change values.
"""
check_config()
message = ''
message_type = 'none'
config = hymby.params
engine_config = hymby.engine.get_config(hymby)
if request.POST.get('save', '').strip():
r = request.POST
config_filename = hymby.params['filename']
# Write changes using an ugly method: Get current config, and update it with form values. Then write all in the config.
conf = ConfigDict().load_config(config_filename)
for field in dict(r):
# do not take save button value
if field == 'save':
continue
value = r[field]
conf.update('general', {field: value})
reset_config(conf)
refresh()
message = 'General configuration updated.'
message_type = 'success'
config = hymby.params # needed as we update it
elif request.POST.get('save_engine'):
r = request.POST
hymby.engine.set_config(hymby, dict(r))
refresh()
message = '%s Configuration updated.' % hymby.params.get('general.engine', '')
message_type = 'success'
engine_config = hymby.engine.get_config(hymby) # needed as we update it
return template('config', title='Configuration', config=config, engine_config=engine_config, message=message, message_type=message_type)
示例2: test_meta
# 需要导入模块: from bottle import ConfigDict [as 别名]
# 或者: from bottle.ConfigDict import update [as 别名]
def test_meta(self):
c = ConfigDict()
c.meta_set('bool', 'filter', bool)
c.meta_set('int', 'filter', int)
c['bool'] = 'I am so true!'
c['int'] = '6'
self.assertTrue(c['bool'] is True)
self.assertEqual(c['int'], 6)
self.assertRaises(ValueError, lambda: c.update(int='not an int'))
示例3: test_namespaces
# 需要导入模块: from bottle import ConfigDict [as 别名]
# 或者: from bottle.ConfigDict import update [as 别名]
def test_namespaces(self):
c = ConfigDict()
c.update('a.b', key='value')
self.assertEqual(c['a.b.key'], 'value')
示例4: test_update
# 需要导入模块: from bottle import ConfigDict [as 别名]
# 或者: from bottle.ConfigDict import update [as 别名]
def test_update(self):
c = ConfigDict()
c['key'] = 'value'
c.update(key='value2', key2='value3')
self.assertEqual(c['key'], 'value2')
self.assertEqual(c['key2'], 'value3')