本文整理汇总了Python中tag.Tag.all方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.all方法的具体用法?Python Tag.all怎么用?Python Tag.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tag.Tag
的用法示例。
在下文中一共展示了Tag.all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from tag import Tag [as 别名]
# 或者: from tag.Tag import all [as 别名]
def post(self):
self.response.headers.add_header("Access-Control-Allow-Origin", "http://www.jonathonduerig.com");
postid = self.request.get("postid")
userid = self.request.get("userid")
posts = []
followed = []
if postid:
query = Post.all()
query.filter("postid = ", postid)
posts = query.fetch(1000)
elif userid:
query = Stream.all()
query.filter("userid = ", userid)
query.order("-created")
posts = query.fetch(30)
query = Relation.all()
query.filter("follower = ", userid)
followed = query.fetch(1000)
resultList = []
for p in posts:
resultTags = []
postkey = ""
outPostid = ""
if postid:
postkey = p.key()
outPostid = postid
else:
postkey = p.postkey.key()
outPostid = p.postkey.postid
query = Tag.all()
query.filter("postkey = ", postkey)
tags = query.fetch(1000)
for t in tags:
found = False
for f in followed:
if t.userid == f.user:
found = True
break
pass
if found or postid:
tag = {'user': t.userid,
'key': t.tag_key,
'value': t.tag_value}
resultTags.append(tag)
pass
resultList.append({'postid': outPostid, 'post': p.post,
'tags': resultTags})
resultStr = json.dumps(resultList, sort_keys=True,
indent=2)
self.response.out.write(resultStr)
示例2: addRelation
# 需要导入模块: from tag import Tag [as 别名]
# 或者: from tag.Tag import all [as 别名]
def addRelation(self, follower, target, existing):
found = False
for cur in existing:
if follower == cur.follower and target == cur.user:
found = True
break
pass
if not found:
relation = Relation(follower=follower, user=target)
relation.put()
query = Tag.all()
query.filter("userid = ", target)
tags = query.fetch(1000)
for tag in tags:
tag.addToStream(follower)