本文整理汇总了Python中models.Setting.get方法的典型用法代码示例。如果您正苦于以下问题:Python Setting.get方法的具体用法?Python Setting.get怎么用?Python Setting.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Setting
的用法示例。
在下文中一共展示了Setting.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_setting_unicode
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import get [as 别名]
def test_setting_unicode(self):
a = Setting.get("test")
self.assertEqual(a.__unicode__(), "test")
a.set_value("e")
self.assertEqual(a.get_value(), "e")
示例2: get_settings
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import get [as 别名]
def get_settings(self):
try:
setting = Setting.get(name=self.setting_name)
return json.loads(setting.value)
except:
Setting.create(
name=self.setting_name,
value=json.dumps(self._settings)
)
return self._settings
示例3: load_deeds
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import get [as 别名]
def load_deeds(self):
if not Setting.get('user_id', None):
self.set_status("Error: Please set user_id and password in settings")
return
sync.load_sync_data(
Setting.get_all(self.db),
on_success=self.sync_load_success,
on_error=self.sync_error,
on_failure=self.sync_error
)
示例4: sync_deeds
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import get [as 别名]
def sync_deeds(self):
if not Setting.get('user_id', None):
self.set_status("Error: Please set user_id and password in settings")
return
sync.sync_data(
self.db.query(Deed).filter_by(synced=False),
Setting.get_all(self.db),
on_success=self.sync_success,
on_error=self.sync_error,
on_failure=self.sync_error
)
示例5: set_settings
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import get [as 别名]
def set_settings(self, **kwargs):
# Only copy valid keys fallback to default settings
vk = self._settings.keys()
kwargs = {k: v for k, v in kwargs.items() if k in vk}
kwargs = dict(self._settings.items() + kwargs.items())
try:
s = Setting.get(name=self.setting_name)
s.value = json.dumps(kwargs)
s.save()
except:
Setting.create(
name=self.setting_name,
value=json.dumps(kwargs),
date_last_updated=datetime.datetime.now()
)
示例6: load_settings_screen_data
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import get [as 别名]
def load_settings_screen_data(self):
"This method runs in main thread and does the backend DB fetching without slowing the UI"
settings_screen = self.get_screen('settings_screen')
settings_screen.txt_user_id.text = Setting.get('user_id', '', db=self.db)
settings_screen.txt_password.text = Setting.get('password', '', db=self.db)