本文整理汇总了Python中models.Setting.get_setting方法的典型用法代码示例。如果您正苦于以下问题:Python Setting.get_setting方法的具体用法?Python Setting.get_setting怎么用?Python Setting.get_setting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Setting
的用法示例。
在下文中一共展示了Setting.get_setting方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import get_setting [as 别名]
def __init__(self, *args, **kwargs):
"""
Overrides the __init__ to fill the form initial data
from database
"""
user = kwargs.get('user', None)
initial = {}
for field_name, obj in self.base_fields.items():
if user:
initial[field_name] = Setting.get_setting(user, field_name)
else:
initial[field_name] = AdminSetting.get_setting(field_name)
kwargs['initial'] = initial
super(BaseSettingForm, self).__init__(*args, **kwargs)
self.user = user
示例2: initialize
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import get_setting [as 别名]
def initialize(self, request, response):
"""initial webapp.RequestHandler"""
webapp.RequestHandler.initialize(self, request, response)
if not self.request.path.endswith('/'):
return self.redirect(self.request.path + "/", True)
self.setting = Setting.get_setting()
self.template_value = {'setting' : self.setting}
# check cookies and find user
cookies = parse_cookie(self.request.headers.get("Cookie", ""))
self.session_key = cookies.get('bitsable-session-key', None)
self.user = None
if self.session_key is not None and len(self.session_key) == 40:
logging.info("session_key:%s" % self.session_key)
self.user = Session.get_user_by_session(self.session_key)
self.template_value['user'] = self.user
示例3: user_setting_value
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import get_setting [as 别名]
def user_setting_value(name):
"""Print user setting value to template"""
return Setting.get_setting(user, name)