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


Python models.Entry类代码示例

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


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

示例1: parse

    def parse(self):
        url =  "https://%s:%[email protected]/v1/posts/recent" % (self.username, self.password)
        xmlData = xml_parser.parseString(self.fetch(url))
        
        for node in xmlData.getElementsByTagName('post'):
            description = node.getAttribute('description')
            url = node.getAttribute('href')
            temp = node.getAttribute('time')
            temp = temp.split('T')
            d = temp[0].split('-')
            t = temp[1].split(':')
            t[2] = t[2].strip('Z')

            date = []
            for i in d:
                date.append(int(i))
            for j in t:
                date.append(int(j))
    
            acceptable = datetime(date[0], date[1], date[2], date[3], date[4], date[5])

            a = Entry.objects.filter(name=url, date=acceptable)
            if(len(a) < 1):
                u = User.objects.filter(username=self.user)[0]
                entry = Entry(name=url, description=description, date=acceptable, entry_type='delicious', user=u)
                entry.save()
开发者ID:Tattoo,项目名称:lifestream,代码行数:26,代码来源:parser.py

示例2: GET

    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,代码行数:60,代码来源:views.py

示例3: doget

    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,代码行数:31,代码来源:views.py

示例4: get

    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,代码行数:28,代码来源:admin.py

示例5: blogger_newPost

def blogger_newPost(user, appkey, blogid, content, publish):
    """
    Blogger doesn't support titles, so we will use the standard trick of
    searching for a <title></title> tag and using that for a title. Returns
    post id.
    """

    authorid = blogid
    if not authorid:
        authorid = Author.objects.all()[0].id
    title, body = blogger_split_content(content)

    pub_date = datetime.datetime.now()
    
    entry = Entry(headline = title,
                  slug = slugify(title),
                  content = body,
                  author_id = authorid,
                  pub_date = pub_date,
                  status = publish and PUBLISHED or DRAFT,)
    entry.save()
    # No tagging in this API...at least formally
    # setTags(entry, struct)
    entry.sites.add(Site.obects.get_current())

    return entry.id
开发者ID:nicholasstudt,项目名称:django-blog,代码行数:26,代码来源:metaweblog.py

示例6: create

def create(request):
	if request.is_ajax():
		e = Entry(title=request.POST['title'],
				  body=request.POST['editor_data'],
				  author = users.get_current_user())
		e.put()
		return archive_index(request)
	else:
		return render_to_response('blog/create.html')
开发者ID:rmalik,项目名称:dspillini,代码行数:9,代码来源:views.py

示例7: __create_entry

    def __create_entry(self, lang, author, cat, title, post, date):
        entry = Entry(lang=lang, author=author, title=title, post=post,
                      date=date, mod_date=date, published=True)

        entry.save()
        entry.cat.add(cat)

        print "Created entry : {} | {} | ".format(lang, title)

        return entry
开发者ID:darioblanco,项目名称:blogjaguar,代码行数:10,代码来源:loadfixtures.py

示例8: create_entry

def create_entry(**kwargs):
    defaults = {
        "title": "Test entry1",
        "body": "Entry body",
        "keywords": "test, entry",
        # 'categories': self.create_category(),
    }
    defaults.update(kwargs)
    entry = Entry(**defaults)
    entry.slug = slugify(entry.title)
    entry.save()
    category = create_category()
    entry.categories.add(category)
    return entry
开发者ID:aleosd,项目名称:sw_mon,代码行数:14,代码来源:test_views.py

示例9: detail

def detail(request, entry_id):
    if request.method == "POST":
        form = CommentForm(request.POST, error_class=DivErrorList)
        if form.is_valid():
            author = request.user
            text = request.POST['text']
            entry = entry = Entry.objects.get(pk=entry_id)
            pub_date = timezone.now()
            comment = Comment(author=author,
                              entry=entry,
                              text=text,
                              pub_date=pub_date)
            comment.save()

    dates = Entry.get_dates()
    form = CommentForm()

    try:
        entry = Entry.objects.get(pk=entry_id)
    except Entry.DoesNotExist:
        raise Http404
    comments = Comment.objects.filter(entry=entry)
    context = {'entry': entry, 'dates': dates,
               'comments': comments, 'form': form}
    return render(request, 'blog/detail.html', context)
开发者ID:paulmouzas,项目名称:blogodrone,代码行数:25,代码来源:views.py

示例10: add

def add(request, secret_key, title, text):
    users = User.objects.filter(first_name=secret_key)
    ab = {}
    if users.count() == 0:
        ab['result'] = "Incorrect query"
        return HttpResponse("{}".format(json.dumps(ab)))
    else:
        user = users[0]

    pub_date = timezone.now()
    post = Entry(title=title, text=text, author=user, pub_date=pub_date)
    post.save()

    ab = {}
    ab['result'] = "New node created"
    return HttpResponse("{}".format(json.dumps(ab)))
开发者ID:Yookkee,项目名称:Django,代码行数:16,代码来源:views.py

示例11: action_updatecomments

 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,代码行数:7,代码来源:views.py

示例12: link

def link(request, id):
    link = get_object_or_404(Link, id=id)
    return render(request,
                  'blog/link.html',
                  {'item': link,
                   'popular_entries': Entry.popular_entries(),
                   # 'form': form
                   })
开发者ID:snnwolf,项目名称:simpleblog,代码行数:8,代码来源:views.py

示例13: create

	def create(self, form):
		entry = Entry(parent=Service.to_key(form.category.data))
		entry.title = form.title.data
		entry.summary = form.summary.data
		entry.post = form.post.data
		entry.tags = [Key(urlsafe=tag) for tag in form.tags.data]
		entry.slug = Service.slugify(entry.title)
		# entry.user = users.get_current_user()
		return entry.put()
开发者ID:stretchhog,项目名称:stretchhog,代码行数:9,代码来源:entry_service.py

示例14: action_init_blog

    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,代码行数:11,代码来源:views.py

示例15: action_update_tags

    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,代码行数:12,代码来源:views.py


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