• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Entry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: entries

def entries(request):

    queryset = Entry.objects.order_by('-publication_date')[:5]
    logged_in = False
    if request.session.get('logged_in'):
        logged_in = True
        if request.method == 'POST':
            form = EntryForm(request.POST)
            if form.is_valid():
                title = form.cleaned_data['title']
                author = User.objects.get(id=request.session.get('user'))
                text = form.cleaned_data['text']
                new_entry = Entry(text=text, title=title, author=author)
                new_entry.save()
                form = EntryForm()
        else:
            form = EntryForm()
    else:
        form = None
        logged_in = False
    e_dict = archive_dict()

    return render(request, 'entry_list.html', {
                  'form': form,
                  'list_of_entries': queryset,
                  'logged_in': logged_in,
                  'e_dict': e_dict},
                  )
开发者ID:cqoverly,项目名称:training.python_web,代码行数:28,代码来源:views.py


示例2: post

 def post(self):
     key = self.get_argument("key", None)
     if key:
         entry = Entry.get(key)
         entry.title = self.get_argument("title")
         entry.markdown = self.get_argument("markdown")
         entry.html = markdown.markdown(self.get_argument("markdown"))
     else:
         title = self.get_argument("title")
         slug = unicodedata.normalize("NFKD", title).encode(
             "ascii", "ignore")
         slug = re.sub(r"[^\w]+", " ", slug)
         slug = "-".join(slug.lower().strip().split())
         if not slug: slug = "entry"
         while True:
             existing = db.Query(Entry).filter("slug =", slug).get()
             if not existing or str(existing.key()) == key:
                 break
             slug += "-2"
         entry = Entry(
             author=self.current_user,
             title=title,
             slug=slug,
             markdown=self.get_argument("markdown"),
             html=markdown.markdown(self.get_argument("markdown")),
         )
     entry.put()
     self.redirect("/entry/" + entry.slug)
开发者ID:footlooze,项目名称:Kowloon-Ice-House,代码行数:28,代码来源:main.py


示例3: get

 def get(self):
     entry_id = self.request.get('entry_id')
     if entry_id:
         try:
             entry_id = int(entry_id)
         except:
             self.response.set_status(400)
             return
         entry = Entry.get_by_id(entry_id)
         if not entry:
             self.response.set_status(404)
             return
         self.send_json(entry.to_dict())
         return
     
     count = self.request.get('count')
     page = self.request.get('page')
     try:
         count = int(count) if count else 20
         page = int(page) if page else 0
     except:
         self.response.set_status(400)
         return
     entries = Entry.get_latest(count, page)
     self.send_json([e.to_dict() for e in entries])
开发者ID:dhconnelly,项目名称:abandoned,代码行数:25,代码来源:api.py


示例4: feed_push_update

def feed_push_update(feed_key):
    feed = ndb.Key(urlsafe=feed_key).get()
    if not feed:
        raise ndb.Return(("No feed", 404))

    data = request.stream.read()

    if feed.hub_secret:
        server_signature = request.headers.get('X-Hub-Signature', None)
        signature = hmac.new(feed.hub_secret, data).hexdigest()

        if server_signature != signature:
            logger.warn('Got PuSH subscribe POST for feed key=%s w/o valid signature: sent=%s != expected=%s', feed_key,
                        server_signature, signature)

            raise ndb.Return('')

    logger.info('Got PuSH body: %s', data)
    logger.info('Got PuSH headers: %s', request.headers)

    parsed_feed = feedparser.parse(data)
    new_guids, old_guids = yield Entry.process_parsed_feed(parsed_feed, feed, overflow=False)
    yield Entry.publish_for_feed(feed, skip_queue=False)

    raise ndb.Return('')
开发者ID:ianmintz,项目名称:pourover,代码行数:25,代码来源:views.py


示例5: edit

def edit(slug):
    if session.get('logged_in'):
        entry = Entry.get_entry(slug, public=False)
    else:
        entry = Entry.get_entry(slug, public=True)
    if entry is None:
        return not_found(404)

    if request.method == 'POST':
        if request.form.get('delete'):
            entry.delete()
            flash('Post supprime', 'danger')
            return redirect(url_for('news'))
        if request.form.get('title') and request.form.get('content'):
            entry.title = request.form['title']
            entry.content = request.form['content']
            entry.published = request.form.get('published') or False
            entry.save()

            flash('Entry saved successfully.', 'success')
            if entry.published:
                return redirect(url_for('detail', slug=entry.slug))
            else:
                return redirect(url_for('edit', slug=entry.slug))
        else:
            flash('Title and Content are required.', 'danger')

    return render_template('edit.html', entry=entry)
开发者ID:clement91190,项目名称:cdj_website,代码行数:28,代码来源:urls.py


示例6: detail

def detail(slug):
  if session.get('logged_in'):
    query = Entry.select()
  else:
    query = Entry.public()
  entry = get_object_or_404(query, Entry.slug == slug)
  return render_template('detail.html', entry=entry)
开发者ID:ephiepark,项目名称:mysite,代码行数:7,代码来源:app.py


示例7: get

    def get(self):

        feed_id, feed_url = self.request.get('feed_id'), \
                self.request.get('feed_url')

        url_result = urllib2.urlopen(feed_url)
        feed_result = fd.parse(url_result)

        if feed_result.bozo == 1:
            logging.error('fetch error, id: %s, url: %s, error: %s', 
                    feed_id, feed_url, feed_result.bozo_exception)
            return

        feed_update_time = feed_result.get('updated', datetime.utcnow)
        has_update = True 

        f = Feed.get_by_id(int(feed_id))
        if f.is_allow_fetch(feed_update_time):
            for entry in feed_result.entries:
                if entry.published_parsed <= f.lastedPublishedTime:
                    logging.info('no updated, id: %s, url: %s', feed_id,
                            feed_url)
                    has_update = False
                    break

                e = Entry(title = entry.title,
                          url = entry.link,
                          author = entry.author,
                          content = entry.content),
                          publishedTime = entry.published_parsed)
                e.put()
                logging.debug('fetch entry, url: %s', entry.link)
开发者ID:tonychi,项目名称:readLater,代码行数:32,代码来源:work.py


示例8: generateFeedEntry

def generateFeedEntry(urlContent,feed):
    encodeType = feed['encoding']
    urlContent = urlContent.decode(encodeType).encode('utf-8')
    global_pattern = re.compile(feed['global_search_pattern'].replace('{%}','(.*?)').replace('{*}','.*?'),re.I|re.S|re.M)
    item_pattern = re.compile(feed['item_search_pattern'].replace('{%}','(.*?)').replace('{*}','.*?'),re.I|re.S|re.M)
    sub_pattern = re.compile(r'{%(.*?)}',re.I|re.S|re.M)
    globalMatch = global_pattern.search(urlContent)
    globalContent = globalMatch.group()
    globalContent = globalContent[0:len(globalContent)/4]
    itemList = item_pattern.findall(globalContent)
    print len(itemList)
    for i in xrange(len(itemList)-1,-1,-1):
        item = itemList[i]
        link = feed['item_link']
        title = feed['item_title']
        content = feed['item_content']
        link = sub_pattern.sub(lambda m: str(item[int(m.group(1))-1]),link)
        content = sub_pattern.sub(lambda m: str(item[int(m.group(1))-1]),content)
        title = sub_pattern.sub(lambda m: str(item[int(m.group(1))-1]),title)
        result = Entry.objects.filter(title=title)
        if len(result) == 0:
            entry = Entry(title=title,link=link,content=content,feedid=feed['id'])
            entry.save()
            if feed['mail_address']!='':
                send_mail(feed['mail_address'], title, link,
          ("smtp.163.com", 25, "[email protected]", "1234qwer", False))
            pass                
        pass
    pass
开发者ID:hdecember,项目名称:RssEverywhere,代码行数:29,代码来源:views.py


示例9: post

    def post(self):
        title = self.get_argument("title", default=None)
        if title is None or len(title) == 0:
            self.view("admin/article-new.html", menuIndex=1, error=u"请输入标题")
            return
        
        email = self.get_current_user()
        user = User.gql("WHERE email = :1", email).get()

        source = self.get_argument("cleanSource", default=" ")
        html = self.get_argument("content", default=" ")
        slug = " "
        if source != " ":
            slug = source.replace("\r\n", " ").replace("\t", "  ")[0:200]

        date = datetime.datetime.now() + datetime.timedelta(hours=8)

        entry = Entry(author=user.key(),
            slug=slug, 
            title=title, 
            html=html, 
            body_source=source,
            published=date,
            updated=date)
        try:
            entry.put()
            self.dispatch(msg=u"创建成功", to=u"文章列表页", toUrl="/admin/article", seconds=2)
        except:
            self.view("admin/article-new.html", menuIndex=1, error=u"创建失败")
开发者ID:youngpay,项目名称:myblog,代码行数:29,代码来源:admin.py


示例10: syncWeibo

def syncWeibo(request):

    WBLogin = weiboLogin.weiboLogin()
    if WBLogin.login('[email protected]','1234qwer')==1:
        urlContent = urllib2.urlopen('http://game.weibo.com/club/forum-315-1').read()
        soup = BeautifulSoup(urlContent)
        ul = soup.find('ul',{'class':'top_topics'})
        lis = ul.findAll('li',{'class':''})

        for li in lis:
            item = {
            'user':li.find('div',{'class':'col1'}).find('img')['alt'],
            'link':li.find('div',{'class':'no_rep_line'}).findAll('a')[1]['href'],
            'tag':li.find('a',{'class':'navy_tag'}).string,
            'title':li.find('div',{'class':'no_rep_line'}).findAll('a')[1].string,
            'time':li.find('div',{'class':'col2'}).find('span').string
            }
            title = "[%s][%s]%s%s"%(item['time'],item['user'],item['tag'],item['title'])
            link = item['link']
            result = Entry.objects.filter(title=title)
            if len(result) == 0:
                entry = Entry(title=title,link=link,content='',feedid=0)
                entry.save()
                send_mail("[email protected]", title, link,
          ("smtp.163.com", 25, "[email protected]", "1234qwer", False))
                pass                
            pass

        return HttpResponse("Login success!") 
    else:
        return HttpResponse("Login error!") 
    pass
开发者ID:hdecember,项目名称:RssEverywhere,代码行数:32,代码来源:views.py


示例11: add_entry

def add_entry(request):
  title = json.loads(request.body)['title']
  text = json.loads(request.body)['text']
  entry = Entry(user=request.user, title=title, text=text)
  entry.save()
  data = json.dumps(Entry.serialize(entry))
  return HttpResponse(data, content_type="application/json")
开发者ID:divyahansg,项目名称:django-react-starter-pack,代码行数:7,代码来源:views.py


示例12: post

 def post(self, entry_id):
   entry = Entry.update_entry(entry_id, self.request2params(self.request))
   if entry is None:
     entry = Entry.get_entry(entry_id)
     return self.redirect('/admin/entry/%d?status=fail' % entry.key.id())
   time.sleep(0.1)
   return self.redirect('/admin/entry/%d?status=done' % entry.key.id())
开发者ID:somin1968,项目名称:mnemonic-official,代码行数:7,代码来源:admin.py


示例13: resave_entries

def resave_entries():
    """ Fetch and re-save all entries """
    entries = db.get_all_entries()
    for item in entries:
        print("Updating entry {} from user {}".format(item.get('id'), item.get('created_by')))
        entry = Entry(id=item.get('id'), created_by=item.get('created_by'))
        entry.save()
开发者ID:pmn,项目名称:qi.io,代码行数:7,代码来源:resave_entries.py


示例14: test_existing_id

 def test_existing_id(self):
     client = Client()
     entry = Entry(title="Hello World!", body="Test Suite action!")
     entry.save()
     pk = entry.id
     response = client.get('/entry/' + str(pk))
     self.assertEqual(response.status_code, 200)
开发者ID:nehalita,项目名称:bloggo,代码行数:7,代码来源:tests.py


示例15: testUndoMyEntry

 def testUndoMyEntry(self):
     try:
         s = get_object_or_404(ProgramSlot, pk=1)
         u = get_object_or_404(User, pk=1)
         e = Entry(pk=2, notes="", slot=s, user=u)
         e.save()
     except Http404, e:
         self.fail("Something doesn't exist.")
开发者ID:joshbohde,项目名称:kelp,代码行数:8,代码来源:tests.py


示例16: index

def index():
    en_tags = Entry.all_tags()
    en = Entry.all_en()
    tags = []
    tags.extend(["".join(x) for x in en_tags])
    unique_tags = []
    for _index in tags:
        unique_tags.extend(_index.split(";"))
    return render_template('index.html', tag_entries=set(unique_tags), entries=en)
开发者ID:cezarsn,项目名称:sec_repo,代码行数:9,代码来源:views.py


示例17: entry_view

def entry_view(entry_id):
    template_name = 'index.html'

    if Entry.select().where(Entry.id == entry_id, Entry.is_active == True, Entry.parent == None).exists():
        entries = Entry.select().where(Entry.id == entry_id, Entry.is_active == True)
        responses = Entry.select().where(Entry.parent << entries)
    else:
        abort(404)

    return views.render(template_name, entries=entries, responses=responses, is_entry=True)
开发者ID:kmasaya,项目名称:bottle.peewee.template,代码行数:10,代码来源:index.py


示例18: delete_feed

def delete_feed(feed_id):
    """Get a feed"""
    feed = Feed.get_by_id(feed_id, parent=g.user.key)
    if not feed:
        return jsonify_error(message="Can't find that feed")

    Entry.delete_for_feed(feed)
    feed.key.delete()

    return jsonify(status='ok')
开发者ID:voidfiles,项目名称:pourover,代码行数:10,代码来源:views.py


示例19: detail

def detail(slug):

    #TODO: implement drafts and publication handling
    if session.get('logged_in'):
        entry = Entry.get_entry(slug, public=False)
    else:
        entry = Entry.get_entry(slug, public=True)
    if entry is None:
        return not_found(404)

    return render_template('detail.html', entry=entry)
开发者ID:clement91190,项目名称:cdj_website,代码行数:11,代码来源:urls.py


示例20: remove_view

def remove_view(entry_id):
    user = Session.get_user()

    if Entry.select().where(Entry.id == entry_id, Entry.user == user, Entry.is_active == True).exists():
        entry = Entry.get(Entry.user == user, Entry.is_active == True)
        entry.is_active = False
        entry.save()
    else:
        abort(404)

    return redirect(URLS['index'])
开发者ID:kmasaya,项目名称:bottle.peewee.template,代码行数:11,代码来源:index.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Event类代码示例发布时间:2022-05-27
下一篇:
Python models.Employee类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap