本文整理汇总了Python中models.Setting.cached_exercises_date方法的典型用法代码示例。如果您正苦于以下问题:Python Setting.cached_exercises_date方法的具体用法?Python Setting.cached_exercises_date怎么用?Python Setting.cached_exercises_date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Setting
的用法示例。
在下文中一共展示了Setting.cached_exercises_date方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_cache_key
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import cached_exercises_date [as 别名]
def get_cache_key(self, exids, dates, title='', showLegend=False):
return "%s|%s|%s|%s|%s" % (Setting.cached_exercises_date(),
sorted(exids), sorted(dates), title, showLegend)
示例2: exercise_title_dicts
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import cached_exercises_date [as 别名]
import layer_cache
from models import Video, Url, Topic, Setting, TopicVersion, Exercise
@layer_cache.cache_with_key_fxn(lambda:
"exercise_title_dicts_%s" % Setting.cached_exercises_date())
def exercise_title_dicts():
return [{
"title": exercise.display_name,
"key": str(exercise.key()),
"relative_url": exercise.relative_url,
"id": exercise.name,
} for exercise in Exercise.get_all_use_cache() if not exercise.summative]
@layer_cache.cache_with_key_fxn(lambda version_number=None:
"video_title_dicts_%s" % (
version_number or Setting.topic_tree_version()))
def video_title_dicts(version_number=None):
if version_number:
version = TopicVersion.get_by_number(version_number)
else:
version = None
return [{
"title": video.title,
"key": str(video.key()),
"relative_url": "/video/%s" % video.readable_id,
"id": video.readable_id
} for video in Video.get_all_live(version=version) if video is not None]
@layer_cache.cache_with_key_fxn(lambda version_number=None:
"url_title_dicts_%s" % (