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


Python Entry.all方法代码示例

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


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

示例1: GET

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
    def GET(self,slug=None,postid=None):
        if postid:
            postid = int(postid)
            entries = Entry.all().filter(published = True).filter(post_id = postid)[0:1]#.fetch(1)
        else:
            slug=urldecode(slug)
            entries = Entry.all().filter(published = True).filter(link = slug)[0:1]#.fetch(1)
        if not entries or len(entries) == 0:
            self.error(404)
            return

        mp=self.paramint("mp",1)

        entry=entries[0]
        if entry.is_external_page:
            self.redirect(entry.external_page_address,True)
        if self.blog.allow_pingback and entry.allow_trackback:
            self.response.headers['X-Pingback']="%s/rpc"%str(self.blog.baseurl)
        entry.readtimes += 1
        entry.put()
        self.entry=entry


        comments=entry.get_comments_by_page(mp,self.blog.comments_per_page)


##        commentuser=self.request.cookies.get('comment_user', '')
##        if commentuser:
##            commentuser=commentuser.split('#@#')
##        else:
        commentuser=['','','']

        comments_nav=self.get_comments_nav(mp,entry.purecomments().count())

        if entry.entrytype=='post':
            self.render('single',
                        {
                        'entry':entry,
                        'relateposts':entry.relateposts,
                        'comments':comments,
                        'user_name':commentuser[0],
                        'user_email':commentuser[1],
                        'user_url':commentuser[2],
                        'checknum1':random.randint(1,10),
                        'checknum2':random.randint(1,10),
                        'comments_nav':comments_nav,
                        })

        else:
            self.render('page',
                        {'entry':entry,
                        'relateposts':entry.relateposts,
                        'comments':comments,
                        'user_name':commentuser[0],
                        'user_email':commentuser[1],
                        'user_url':commentuser[2],
                        'checknum1':random.randint(1,10),
                        'checknum2':random.randint(1,10),
                        'comments_nav':comments_nav,
                        })
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:62,代码来源:views.py

示例2: get

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
    def get(self):

        item_type = self.request.get('item')
        if item_type == "entry":
            object_list = Entry.all()
        elif item_type == "country":
            object_list = Country.all()
        else:
            item_type = None
            object_list = Entry.all()

        object_list = object_list.order('-publish_date')
        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 = {
            'object_list': object_list,
            'item_type': item_type,
            'url': url,
            'url_linktext': url_linktext,
        }

        path = os.path.join(os.path.dirname(__file__), 'templates/admin/view.html')
        self.response.out.write(template.render(path, template_values))
开发者ID:kelvinn,项目名称:gae-demo-blog,代码行数:30,代码来源:admin.py

示例3: action_updatecomments

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
 def action_updatecomments(self):
     for entry in Entry.all():
         cnt=entry.comments().count()
         if cnt<>entry.commentcount:
             entry.commentcount=cnt
             entry.put()
     self.write(_('"All comments updated"'))
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:9,代码来源:views.py

示例4: doget

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
    def doget(self,page):
        page=int(page)
        #entrycount=self.blog.postscount()
        entrycount=Entry.postscount()
        max_page = entrycount / self.blog.posts_per_page + ( entrycount % self.blog.posts_per_page and 1 or 0 )

        if page < 1 or page > max_page:
            return self.error(404)

        offset_start = (page-1) * self.blog.posts_per_page
        offset_end = offset_start + self.blog.posts_per_page
        entries = Entry.all().filter(entrytype = 'post').\
                filter(published = True).order_by('-date')[offset_start:offset_end]#.\
                #fetch(self.blog.posts_per_page, offset = (page-1) * self.blog.posts_per_page)
        #import pdb; pdb.set_trace()

        show_prev =entries and  (not (page == 1))
        #show_prev = True
        show_next =entries and  (not (page == max_page))
        #show_next = True
        #print page,max_page,self.blog.entrycount,self.blog.posts_per_page


        self.render('index',{'entries':entries,
                           'show_prev' : show_prev,
                        'show_next' : show_next,
                        'pageindex':page,
                        'ishome':True,
                        'pagecount':max_page,
                        'postscounts':entrycount
                            })
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:33,代码来源:views.py

示例5: action_init_blog

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
    def action_init_blog(self,slug=None):

        for com in Comment.all():
            com.delete()

        for entry in Entry.all():
            entry.delete()

        self.blog.entrycount=0
        self.blog.save()
        self.write(_('"Init has succeed."'))
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:13,代码来源:views.py

示例6: clean_gae

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
def clean_gae():
   query = Entry.all()
   entries =query.fetch(1000)
   db.delete(entries)

   query = Country.all()
   countries = query.fetch(1000)
   db.delete(countries)

   query = Tag.all()
   tags = query.fetch(1000)
   db.delete(tags)
开发者ID:kelvinn,项目名称:gae-demo-blog,代码行数:14,代码来源:myhelpers.py

示例7: action_update_tags

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
    def action_update_tags(self,slug=None):
        for tag in Tag.all():
            tag.delete()
        for entry in Entry.all().filter('entrytype =','post'):
            if entry.tags:
                for t in entry.tags:
                    try:
                        Tag.add(t)
                    except:
                        traceback.print_exc()

        self.write(_('"All tags for entry have been updated."'))
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:14,代码来源:views.py

示例8: initialize

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
 def initialize(self, request):
     m_pages=Entry.all().filter('entrytype =','page')\
         .filter('published =',True)\
         .filter('entry_parent =',0)\
         .order('menu_order')
     blogroll=Link.all().filter('linktype =','blogroll')
     archives=Archive.all().order('-year').order('-month').fetch(12)
     alltags=Tag.all()
     self.template_vals.update({
                     'menu_pages':m_pages,
                     'categories':Category.all(),
                     'blogroll':blogroll,
                     'archives':archives,
                     'alltags':alltags,
                     'recent_comments':Comment.all().order('-date').fetch(5)
     })
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:18,代码来源:views.py

示例9: action_updatelink

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
    def action_updatelink(self):
        link_format=self.param('linkfmt')

        if link_format:
            link_format=link_format.strip()
            self.blog.link_format=link_format
            self.blog.save()
            for entry in Entry.all():
                vals={'year':entry.date.year,'month':str(entry.date.month).zfill(2),'day':entry.date.day,
                'postname':entry.slug,'post_id':entry.post_id}

                if entry.slug:
                    newlink=link_format%vals
                else:
                    newlink=self.blog.default_link_format%vals

                if entry.link<>newlink:
                    entry.link=newlink
                    entry.put()
            self.write(_('"Link formated succeed"'))
        else:
            self.write(_('"Please input url format."'))
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:24,代码来源:views.py

示例10: action_update_archives

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
    def action_update_archives(self,slug=None):
        for archive in Archive.all():
            archive.delete()
        entries=Entry.all().filter('entrytype =','post')

        archives={}


        for entry in entries:
            my = entry.date.strftime('%B %Y') # September-2008
            sy = entry.date.strftime('%Y') #2008
            sm = entry.date.strftime('%m') #09
            if archives.has_key(my):
                archive=archives[my]
                archive.entrycount+=1
            else:
                archive = Archive(monthyear=my,year=sy,month=sm,entrycount=1)
                archives[my]=archive

        for ar in archives.values():
            ar.put()

        self.write(_('"All entries have been updated."'))
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:25,代码来源:views.py

示例11: sticky_entrys

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
	def sticky_entrys(self):
		return Entry.all().filter('entrytype =','post')\
			.filter('published =',True)\
			.filter('sticky =',True)\
			.order('-date')
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:7,代码来源:views.py

示例12: home

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
def home(request):
	entries = Entry.all()
	entries.order('-published')
	entries.fetch(limit=5)
	events = fetch_events()
	return render_to_response('home.html', {'events': events[0:5], 'entries':entries})
开发者ID:rmalik,项目名称:dspillini,代码行数:8,代码来源:views.py

示例13: POST

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
    def POST(self,slug=None,postid=None):
        '''handle trackback'''
        error = '''<?xml version="1.0" encoding="utf-8"?>
<response>
<error>1</error>
<message>%s</message>
</response>
'''
        success = '''<?xml version="1.0" encoding="utf-8"?>
<response>
<error>0</error>
</response>
'''

        if not self.blog.allow_trackback:
            self.response.out.write(error % "Trackback denied.")
            return
        self.response.headers['Content-Type'] = "text/xml"
        if postid:
            entries = Entry.all().filter(published = True).filter(post_id = postid)[0:1]#.fetch(1)
        else:
            slug=urldecode(slug)
            entries = Entry.all().filter(published = True).filter(link = slug)[0:1]#.fetch(1)

        if not entries or len(entries) == 0 :#or  (postid and not entries[0].link.endswith(self.blog.default_link_format%{'post_id':postid})):
            self.response.out.write(error % "empty slug/postid")
            return
        #check code ,rejest spam
        entry=entries[0]
        logging.info(self.request.remote_addr+self.request.path+" "+entry.trackbackurl)
        #key=self.param("code")
        #if (self.request.uri!=entry.trackbackurl) or entry.is_external_page or not entry.allow_trackback:
        #import cgi
        from urlparse import urlparse
        param=urlparse(self.request.uri)
        code=param[4]
        param=cgi.parse_qs(code)
        if param.has_key('code'):
            code=param['code'][0]

        if  (not str(entry.key())==code) or entry.is_external_page or not entry.allow_trackback:
            self.response.out.write(error % "Invalid trackback url.")
            return


        coming_url = self.param('url')
        blog_name = myfilter.do_filter(self.param('blog_name'))
        excerpt = myfilter.do_filter(self.param('excerpt'))
        title = myfilter.do_filter(self.param('title'))

        if not coming_url or not blog_name or not excerpt or not title:
            self.response.out.write(error % "not enough post info")
            return

        import time
        #wait for half second in case otherside hasn't been published
        time.sleep(0.5)

##        #also checking the coming url is valid and contains our link
##        #this is not standard trackback behavior
##        try:
##
##            result = urlfetch.fetch(coming_url)
##            if result.status_code != 200 :
##                #or ((self.blog.baseurl + '/' + slug) not in result.content.decode('ascii','ignore')):
##                self.response.out.write(error % "probably spam")
##                return
##        except Exception, e:
##            logging.info("urlfetch error")
##            self.response.out.write(error % "urlfetch error")
##            return

        comment = Comment.all().filter(entry = entry).filter(weburl = coming_url).get()
        if comment:
            self.response.out.write(error % "has pinged before")
            return

        comment=Comment(author=blog_name,
                content="...<strong>"+title[:250]+"</strong> " +
                        excerpt[:250] + '...',
                weburl=coming_url,
                entry=entry)

        comment.ip=self.request.remote_addr
        comment.ctype=COMMENT_TRACKBACK
        try:
            comment.save()

            memcache.delete("/"+entry.link)
            self.write(success)
            self.blog.tigger_action("pingback_post",comment)
        except:
            self.response.out.write(error % "unknow error")
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:95,代码来源:views.py

示例14: action_updatecommentno

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
 def action_updatecommentno(self):
     for entry in Entry.all():
         entry.update_commentno()
     self.write(_('"All comments number Updates."'))
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:6,代码来源:views.py

示例15: items

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import all [as 别名]
 def items(self):
     return Entry.all()
开发者ID:raychorn,项目名称:DjangoSample1,代码行数:4,代码来源:sitemaps.py


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