本文整理汇总了Python中models.Comment.get_comments方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.get_comments方法的具体用法?Python Comment.get_comments怎么用?Python Comment.get_comments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Comment
的用法示例。
在下文中一共展示了Comment.get_comments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stream
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import get_comments [as 别名]
def stream(category):
if category == 'popular' or category == 'recent':
if category == 'popular':
mode = 'public'
else:
mode = 'full'
if g.user.is_authenticated():
g.user = current_user
minx = (float)(g.user.location.split(",",2)[0])
miny = (float)(g.user.location.split(",",2)[1])
else:
minx = 12.97160
miny = 77.59456
maxx = minx+30.0
maxy = miny+30.0
params = urllib.urlencode({'set': mode, 'from': 0, 'to': 20, 'minx': minx, 'miny': miny, 'maxx': maxx, 'maxy': maxy, 'size':'medium', 'mapfilter': 'true'})
result = urllib.urlopen("http://www.panoramio.com/map/get_panoramas.php?%s" % params)
data = json.loads(result.read())
for photo in data['photos']:
comment = Comment.get_comments(Comment, int(photo['photo_id']))
if len(comment) != 0:
photo['comments'] = comment
else:
photo['comments'] = None
return render_template('stream.html',
user = g.user,
data=data,
cat=category,
activity=g.activity,
myActivity=g.my_activity)
return render_template('404.html')
示例2: get
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import get_comments [as 别名]
def get(self, digits):
print(digits)
requested_id = int(digits)
post = Post.get_by_id(requested_id)
error = ''
comments = Comment.get_comments(post)
print(comments)
if not post:
error = 'Requested post not found :('
if comments:
self.render("post.html", error=error, post=post, comments=comments)
else:
self.render("post.html", error=error, post=post)