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


Python Tag.all方法代码示例

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

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


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