本文整理汇总了Python中stream.Stream.all方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.all方法的具体用法?Python Stream.all怎么用?Python Stream.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stream.Stream
的用法示例。
在下文中一共展示了Stream.all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addToStream
# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import all [as 别名]
def addToStream(self, follower):
query = Stream.all()
query.filter("userid = ", follower)
query.filter("postkey = ", self.postkey)
result = query.fetch(1000)
if len(result) == 0:
stream = Stream()
stream.userid = follower
stream.postkey = self.postkey
stream.post = self.postkey.post #Post.get(self.postkey)
stream.put()
示例2: post
# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream 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)