本文整理汇总了Python中video_models.Video.get_for_readable_id方法的典型用法代码示例。如果您正苦于以下问题:Python Video.get_for_readable_id方法的具体用法?Python Video.get_for_readable_id怎么用?Python Video.get_for_readable_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类video_models.Video
的用法示例。
在下文中一共展示了Video.get_for_readable_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_video
# 需要导入模块: from video_models import Video [as 别名]
# 或者: from video_models.Video import get_for_readable_id [as 别名]
def show_video(handler, readable_id, topic_id,
redirect_to_canonical_url=False):
topic = None
query_string = ''
if topic_id is not None and len(topic_id) > 0:
topic = Topic.get_by_id(topic_id)
key_id = 0 if not topic else topic.key().id()
# If a topic_id wasn't specified or the specified topic wasn't found
# use the first topic for the requested video.
if topic is None:
# Get video by readable_id to get the first topic for the video
video = Video.get_for_readable_id(readable_id)
if video is None:
raise MissingVideoException("Missing video '%s'" %
readable_id)
topic = video.first_topic()
if not topic:
raise MissingVideoException("No topic has video '%s'" %
readable_id)
if handler.request.query_string:
query_string = '?' + handler.request.query_string
redirect_to_canonical_url = True
if redirect_to_canonical_url:
url = "/%s/v/%s%s" % (topic.get_extended_slug(),
urllib.quote(readable_id),
query_string)
logging.info("Redirecting to %s" % url)
handler.redirect(url, True)
return None
# Note: Bingo conversions are tracked on the client now,
# so they have been removed here. (tomyedwab)
topic_data = topic.get_play_data()
discussion_options = qa.add_template_values({}, handler.request)
video_data = Video.get_play_data(readable_id, topic,
discussion_options)
if video_data is None:
raise MissingVideoException("Missing video '%s'" % readable_id)
template_values = {
"topic_data": topic_data,
"topic_data_json": api.jsonify.jsonify(topic_data),
"video": video_data,
"video_data_json": api.jsonify.jsonify(video_data),
"selected_nav_link": 'watch',
}
return template_values