本文整理汇总了Python中models.point.Point.findCurrent_async方法的典型用法代码示例。如果您正苦于以下问题:Python Point.findCurrent_async方法的具体用法?Python Point.findCurrent_async怎么用?Python Point.findCurrent_async使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.point.Point
的用法示例。
在下文中一共展示了Point.findCurrent_async方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createTemplateValues
# 需要导入模块: from models.point import Point [as 别名]
# 或者: from models.point.Point import findCurrent_async [as 别名]
def createTemplateValues(self, url):
templateValues = {}
point = None
pointRoot = None
if url:
point, pointRoot = yield Point.findCurrent_async(url)
if point.url != url:
self.redirect(str(point.url))
else:
templateValues = {
'user': self.current_user,
'message': "URL or Key must be supplied.",
'currentArea': self.session.get('currentArea'),
'currentAreaDisplayName': self.session.get('currentAreaDisplayName')
}
if not point:
templateValues = {
'user': self.current_user,
'message': "Could not find point. Some points are in private classrooms and you \
need to be logged in and authorized to view them.",
'currentArea': self.session.get('currentArea'),
'currentAreaDisplayName': self.session.get('currentAreaDisplayName')
}
else: # we have a point!
user = self.current_user
if user:
user.updateRecentlyViewed(point.key.parent())
user.getActiveNotifications()
templateValues = {
'user': user,
'currentArea':self.session.get('currentArea'),
'currentAreaDisplayName':self.session.get('currentAreaDisplayName'),
'notifications': user.notifications if user else None
}
self.add_react_json(templateValues)
raise ndb.Return(templateValues)
示例2: createTemplateValues
# 需要导入模块: from models.point import Point [as 别名]
# 或者: from models.point.Point import findCurrent_async [as 别名]
def createTemplateValues(self, url=None, full=True, rootKey=None):
newURL = None
templateValues = {}
point = None
pointRoot = None
if url:
point, pointRoot = yield Point.findCurrent_async(url)
elif rootKey:
point, pointRoot = Point.getCurrentByRootKey(rootKey)
else:
templateValues = {
'user': self.current_user,
'message': "URL or Key must be supplied.",
'currentArea': self.session.get('currentArea'),
'currentAreaDisplayName': self.session.get('currentAreaDisplayName')
}
if not point:
templateValues = {
'user': self.current_user,
'message': "Could not find point. Some points are in private classrooms and you \
need to be logged in and authorized to view them.",
'currentArea': self.session.get('currentArea'),
'currentAreaDisplayName': self.session.get('currentAreaDisplayName')
}
else: # we have a point!
voteValue = 0
ribbonValue = False
addedToRecentlyViewed = False
user = self.current_user
# supportingPoints, counterPoints = point.getAllLinkedPoints(user)
# We need to get the recently viewed points here
# Because the user can add them as counter/supporting points
if user:
vote, relevanceVotes, recentlyViewed, sources, supportingPoints, counterPoints = yield \
user.getVote_async(point.key.parent()), \
user.getRelevanceVotes_async(point), \
user.getRecentlyViewed_async( \
excludeList=[point.key.parent()] + \
point.getLinkedPointsRootKeys("supporting") + \
point.getLinkedPointsRootKeys("counter")), \
point.getSources_async(), \
point.getLinkedPoints_async("supporting", user), \
point.getLinkedPoints_async("counter", user)
point.addRelevanceVotes(relevanceVotes, supportingPoints, counterPoints)
addedToRecentlyViewed = user.updateRecentlyViewed(point.key.parent())
else:
sources, supportingPoints, counterPoints = yield point.getSources_async(), \
point.getLinkedPoints_async("supporting", None), \
point.getLinkedPoints_async("counter", None)
recentlyViewed = None
# For now add to a point's view count if user is not logged in or if view point is added to the recently viewed list
if addedToRecentlyViewed or not user:
viewCountFuture = pointRoot.addViewCount()
if user:
voteValue = vote.value if vote else 0
ribbonValue = vote.ribbon if vote else False
# viewCountFuture.get_result()
templateValues = {
'point': point,
'pointRoot': pointRoot,
'recentlyViewedPoints': recentlyViewed,
'supportingPoints': supportingPoints,
'counterPoints': counterPoints,
'supportedPoints':pointRoot.getBacklinkPoints("supporting"),
'counteredPoints':pointRoot.getBacklinkPoints("counter"),
'sources': sources,
'user': user,
'voteValue': voteValue,
'ribbonValue': ribbonValue,
'currentArea':self.session.get('currentArea'),
'currentAreaDisplayName':self.session.get('currentAreaDisplayName')
}
if full:
if user:
user.getActiveNotifications()
templateValues['notifications'] = user.notifications if user else None,
templateValues['comments'] = pointRoot.getComments()
raise ndb.Return(templateValues)