当前位置: 首页>>代码示例>>Python>>正文


Python Setting.value方法代码示例

本文整理汇总了Python中models.Setting.value方法的典型用法代码示例。如果您正苦于以下问题:Python Setting.value方法的具体用法?Python Setting.value怎么用?Python Setting.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Setting的用法示例。


在下文中一共展示了Setting.value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __setattr__

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import value [as 别名]
 def __setattr__(self, name, value):
     if name in ('_vals', '_name', '_appname', '_verbose_name', '_readonly', '_cache_prefix', '_main'):
         return object.__setattr__(self, name, value)
     if self._readonly:
         raise AttributeError, 'settings group %s is read-only' % self._name
     if not name in self._vals:
         raise AttributeError, 'setting "%s" not found'%name
     if not has_db:
         raise SettingsException, "no database -- settings are immutable"
     self._vals[name].initial = self._vals[name].clean(value)
     try:
         setting = Setting.objects.get(app = self._appname,
                 site = Site.objects.get_current(),
                 class_name = self._name,
                 key = name)
     except Setting.DoesNotExist:
         setting = Setting(site = Site.objects.get_current(),
                 app = self._appname,
                 class_name = self._name,
                 key = name)
     serialized = value
     if hasattr(self._vals[name].widget, '_format_value'):
         serialized = self._vals[name].widget._format_value(value)
     serialized = force_unicode(serialized)
     setting.value = serialized
     setting.save()
     if appsettings.USE_CACHE:
         cache.set(self._cache_prefix+name, value)
     if self._main:
         setattr(django_settings, name, value)
开发者ID:smacker,项目名称:django-appsettings,代码行数:32,代码来源:settingsobj.py

示例2: set_value

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import value [as 别名]
	def set_value(self, key, value):
		setting = Setting.query.filter(Setting.key == key).first()
		if setting is None:
			setting = Setting(key,'')
			db.session.add(setting)
		# self.logger.debug('setting {0} to {1}'.format(key, value))
		setting.value = value
		db.session.commit()
开发者ID:box-community,项目名称:box-hero-report,代码行数:10,代码来源:box.py


注:本文中的models.Setting.value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。