Example #1
0
	def doget(self,page):
		from model import g_blog
		page=int(page)
		entrycount=g_blog.postscount()
		posts_per_page = OptionSet.getValue("posts_per_page",default="8")
		if posts_per_page:
			posts_per_page = 8
		max_page = entrycount / posts_per_page + ( entrycount % posts_per_page and 1 or 0 )
		comments=Comment.all().order('-date').fetch(5)

		if page < 1 or page > max_page:
			return Error404

		entries = Entry.all().filter('entrytype =','post').\
				filter("published =", True).order('-date').\
				fetch(posts_per_page, offset = (page-1) * posts_per_page)

		show_prev =entries and  (not (page == 1))
		show_next =entries and  (not (page == max_page))


		self.render2("plugins/wapblog/index.html",{'entries':entries,
						'show_prev' : show_prev,
						'show_next' : show_next,
						'pageindex':page,
						'ishome':True,
                        'pagecount':max_page,
                        'postscount':entrycount,
						'comments':comments
							})
Example #2
0
	def doget(self,page):
		try:
			from model import g_blog
		except:
			pass
		page=int(page)
		time=datetime.now()
		entrycount=g_blog.postscount()
		posts_per_page = OptionSet.getValue("posts_per_page",default="8")
		if posts_per_page:
			posts_per_page = 8
		max_page = entrycount / posts_per_page + ( entrycount % posts_per_page and 1 or 0 )
		comments=memcache.get("wap_comments"+self.request.path_qs)
		if comments is None:
			comments=Comment.all().order('-date').fetch(5)
			memcache.set("wap_comments"+self.request.path_qs,comments)

		if page < 1 or page > max_page:
			return self.error(404)
		entries=memcache.get("wap_entries"+self.request.path_qs)
		if entries is None :
			entries = Entry.all().filter('entrytype =','post').\
					filter("published =", True).order('-date').\
					fetch(posts_per_page, offset = (page-1) * posts_per_page)
			memcache.set("wap_entries"+self.request.path_qs,entries)

		show_prev =entries and  (not (page == 1))
		show_next =entries and  (not (page == max_page))


		self.render2("plugins/wapblog/index.html",{'entries':entries,
						'show_prev' : show_prev,
						'show_next' : show_next,
						'pageindex':page,
						'time':time,
						'ishome':True,
                        'pagecount':max_page,
                        'postscount':entrycount,
						'comments':comments
							})
Example #3
0
    def doget(self, page):
        from model import g_blog

        page = int(page)
        entrycount = g_blog.postscount()
        posts_per_page = OptionSet.getValue("posts_per_page", default="8")
        if posts_per_page:
            posts_per_page = 8
        max_page = entrycount / posts_per_page + (entrycount % posts_per_page and 1 or 0)
        comments = Comment.all().order("-date").fetch(5)

        if page < 1 or page > max_page:
            return Error404

        entries = (
            Entry.all()
            .filter("entrytype =", "post")
            .filter("published =", True)
            .order("-date")
            .fetch(posts_per_page, offset=(page - 1) * posts_per_page)
        )

        show_prev = entries and (not (page == 1))
        show_next = entries and (not (page == max_page))

        self.render2(
            "plugins/wapblog/index.html",
            {
                "entries": entries,
                "show_prev": show_prev,
                "show_next": show_next,
                "pageindex": page,
                "ishome": True,
                "pagecount": max_page,
                "postscount": entrycount,
                "comments": comments,
            },
        )