本文整理汇总了Python中r2.models.keyvalue.NamedGlobals.get方法的典型用法代码示例。如果您正苦于以下问题:Python NamedGlobals.get方法的具体用法?Python NamedGlobals.get怎么用?Python NamedGlobals.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类r2.models.keyvalue.NamedGlobals
的用法示例。
在下文中一共展示了NamedGlobals.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GET_index
# 需要导入模块: from r2.models.keyvalue import NamedGlobals [as 别名]
# 或者: from r2.models.keyvalue.NamedGlobals import get [as 别名]
def GET_index(self):
quote = self._get_quote()
images = self._get_images()
stats = NamedGlobals.get("about_reddit_stats", None)
content = About(
quote=quote,
images=images,
stats=stats,
events=g.plugins["about"].timeline_data,
sites=g.plugins["about"].sites_data,
)
return AboutPage("about-main", _("we power awesome communities."), _("about reddit"), content).render()
示例2: get_current_press
# 需要导入模块: from r2.models.keyvalue import NamedGlobals [as 别名]
# 或者: from r2.models.keyvalue.NamedGlobals import get [as 别名]
def get_current_press():
key = _CURRENT_PRESS_KEY()
val = g.thebuttoncache.get(key)
if val is None:
try:
val = NamedGlobals.get(key)
except NotFoundException:
val = NONE
g.thebuttoncache.set(key, val)
if val == NONE:
return None
elif val:
return _deserialize_datetime(val)
示例3: GET_index
# 需要导入模块: from r2.models.keyvalue import NamedGlobals [as 别名]
# 或者: from r2.models.keyvalue.NamedGlobals import get [as 别名]
def GET_index(self):
quote = self._get_quote()
images = self._get_images()
stats = NamedGlobals.get('about_reddit_stats', None)
c.js_preload.set('#images', images)
content = About(
quote=quote,
images=images,
stats=stats,
events=g.plugins['about'].timeline_data,
sites=g.plugins['about'].sites_data,
)
return AboutPage(
content_id='about-main',
title_msg=_('we power awesome communities.'),
pagename=_('about reddit'),
content=content,
).render()
示例4: has_timer_expired
# 需要导入模块: from r2.models.keyvalue import NamedGlobals [as 别名]
# 或者: from r2.models.keyvalue.NamedGlobals import get [as 别名]
def has_timer_expired():
# note: this only checks if the timer has been marked as expired, it doesn't
# actually check its value (that's done in check_timer)
key = _EXPIRED_KEY()
val = g.thebuttoncache.get(key)
if val is None:
try:
val = NamedGlobals.get(key)
except NotFoundException:
# has never been set, set the key
val = False
NamedGlobals.set(key, val)
# update the cache
g.thebuttoncache.set(key, val)
if val:
return _deserialize_datetime(val)
return val
示例5: health_check
# 需要导入模块: from r2.models.keyvalue import NamedGlobals [as 别名]
# 或者: from r2.models.keyvalue.NamedGlobals import get [as 别名]
def health_check():
"""Calculate the number of seconds since promotions were last updated"""
return time.time() - int(NamedGlobals.get(PROMO_HEALTH_KEY, default=0))
示例6: get_trending_subreddits
# 需要导入模块: from r2.models.keyvalue import NamedGlobals [as 别名]
# 或者: from r2.models.keyvalue.NamedGlobals import get [as 别名]
def get_trending_subreddits():
return NamedGlobals.get(TRENDING_SUBREDDITS_KEY, None)
示例7: health_check
# 需要导入模块: from r2.models.keyvalue import NamedGlobals [as 别名]
# 或者: from r2.models.keyvalue.NamedGlobals import get [as 别名]
def health_check():
return NamedGlobals.get(PROMO_HEALTH_KEY, default=0)