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


Python Post.all方法代码示例

本文整理汇总了Python中post.Post.all方法的典型用法代码示例。如果您正苦于以下问题:Python Post.all方法的具体用法?Python Post.all怎么用?Python Post.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在post.Post的用法示例。


在下文中一共展示了Post.all方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
 def get(self):
     posts = Post.all().order('-created')
 	
     if self.user:
        self.render('front.html', posts = posts,username = self.user.name)
     else:
         self.render('front.html', posts = posts)
开发者ID:YouYue123,项目名称:Fullstack-Udacity,代码行数:9,代码来源:main.py

示例2: get

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
    def get(self):
        """
            This renders home page with all posts, sorted by date.
        """

        deleted_post_id = self.request.get('deleted_post_id')
        posts = greetings = Post.all().order('-created')
        self.render('welcome.html', posts=posts,
                    deleted_post_id=deleted_post_id)
开发者ID:Ahmed-elsayed-mahmoud,项目名称:Project-3_Multi-User-Blog,代码行数:11,代码来源:blog.py

示例3: get

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
  def get(self):
    posts = Post.all()
    if not config.DEBUG and not self.request.host_url.endswith('appspot.com'):
      posts.filter('confirmed_at !=', None)
    posts.order('-confirmed_at')

    values = {
      'posts': posts
    }
    self.response.out.write(helper.render('main', values))
开发者ID:grunskis,项目名称:neperczagtu.lv,代码行数:12,代码来源:main.py

示例4: get

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
 def get(self, post_id=None, action=None):
     if action is None:
         posts = Post.all()
         self.response.out.write(helper.render('admin/posts', { 'posts': posts }))
     elif action == "delete":
         Post.get_by_id(int(post_id)).delete()
         return self.redirect('/admin/posts')
     elif action == "confirm":
         post = Post.get_by_id(int(post_id))
         post.confirmed_at = datetime.datetime.today()
         post.put()
         return self.redirect('/admin/posts')
开发者ID:grunskis,项目名称:neperczagtu.lv,代码行数:14,代码来源:admin.py

示例5: post

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post 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

示例6: get

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
    def get(self):
        posts_query = Post.all().order('-date')
        paginator = GAEPaginator(posts_query, 100)
        
        page = self.request.GET.get('page', 1)
        try:
            posts = paginator.page(page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            posts = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            posts = paginator.page(paginator.num_pages)
        
        visible_posts = posts.object_list
        columns = [[], [], []]
        
        # TODO: calculate contributor ranking fer reals
        contributors = {}
        for i in range(len(visible_posts)):
            columns[i % len(columns)].append(visible_posts[i])
            if not visible_posts[i].author:
                continue
            if visible_posts[i].author in contributors:
                contributors[visible_posts[i].author] += 1
            else:
                contributors[visible_posts[i].author] = 1
        
        sorted_contributors = sorted(contributors.iteritems(), key=operator.itemgetter(1))
        sorted_contributors.reverse()
        top_contributors = sorted_contributors[0:min(3, len(contributors))]
        
        if users.get_current_user():
            url = users.create_logout_url(self.request.uri)
            url_linktext = 'Logout'
        else:
            url = users.create_login_url(self.request.uri)
            url_linktext = 'Login'

        template_values = {
            'top_contributors': top_contributors,
            'columns': columns,
            'url': url,
            'url_linktext': url_linktext,
            'posts': posts,
        }

        path = os.path.join(os.path.dirname(__file__), 'index.html')
        self.response.out.write(template.render(path, template_values))
开发者ID:sephiria,项目名称:sandbox,代码行数:51,代码来源:main.py

示例7: post

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
 def post(self):
     self.response.headers.add_header("Access-Control-Allow-Origin", "http://www.jonathonduerig.com");
     postid = self.request.get("postid")
     post = self.request.get("post")
     user = self.request.get("user")
     key = self.request.get("key")
     value = self.request.get("value")
     query = Post.all()
     query.filter("postid = ", postid)
     postResult = query.fetch(1000)
     post = Post(postid=postid, post=post)
     if len(postResult) > 0:
         post = postResult[0]
     else:
         post.put()
     tag = Tag(userid=user, postkey=post.key(), tag_key=key, tag_value=value)
     tag.put()
     query = Relation.all()
     query.filter("user = ", user)
     followers = query.fetch(1000)
     for f in followers:
         tag.addToStream(f.follower)
     self.response.out.write("Tagged post " + postid + " with " + user + ":" +
                             key + "=" + value)
开发者ID:duerig,项目名称:sentagstream,代码行数:26,代码来源:tagpost.py

示例8: get

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
 def get(self):
     posts = Post.all().order('-created_at')
     self.render('front.html', posts=posts)
开发者ID:sbagdat,项目名称:multiplog,代码行数:5,代码来源:main.py

示例9: get

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import all [as 别名]
 def get(self):
     posts = greetings = Post.all().order('-created')
     self.render('front.html', posts = posts)
开发者ID:ttu,项目名称:scratchpad,代码行数:5,代码来源:blog.py


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