当前位置: 首页>>代码示例>>Python>>正文


Python Stream.all方法代码示例

本文整理汇总了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()
开发者ID:duerig,项目名称:sentagstream,代码行数:13,代码来源:tag.py

示例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)
开发者ID:duerig,项目名称:sentagstream,代码行数:52,代码来源:getpost.py


注:本文中的stream.Stream.all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。