本文整理汇总了Python中models.Entry.content方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.content方法的具体用法?Python Entry.content怎么用?Python Entry.content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Entry
的用法示例。
在下文中一共展示了Entry.content方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pull_feeds
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import content [as 别名]
def pull_feeds(request):
sources = Source.objects.filter(usersource__user=request.user)
for source in sources:
if source.xml_url:
d = feedparser.parse(source.xml_url)
#update source with attributes from feed
if 'icon' in d.feed:
source.icon_url = d.feed.icon
if 'updated_parsed' in d.feed and d.feed.updated_parsed is not None:
source.updated_parsed = datetime.fromtimestamp(mktime(d.feed.updated_parsed))
source.save()
#print [field for field in d]
for e in d['entries']:
if 'published_parsed' in e:
entry_published_date = datetime.fromtimestamp(mktime(e.published_parsed)) #feed timestamp
if source.updated_parsed is None or entry_published_date>source.updated_parsed:
entry = Entry(source=source, title=e.title, raw=e)
if 'author_detail' in e:
if 'name' in e.author_detail:
entry.author_name = e.author_detail.name
if 'href' in e.author_detail:
entry.author_href = e.author_detail.href
if 'email' in e.author_detail:
entry.author_email = e.author_detail.email
if 'comments' in e:
entry.comments_href = e.comments
if 'content' in e:
entry.content = e.content
if 'contributors' in e:
entry.contributors = e.contributors
if 'link' in e:
entry.link = e.link
if 'links' in e:
entry.links = e.links
if 'created_parsed' in e:
entry.created_parsed = datetime.fromtimestamp(mktime(e.created_parsed)) #feed timestamp
if 'expired_parsed' in e:
entry.expired_parsed = datetime.fromtimestamp(mktime(e.expired_parsed)) #feed timestamp
if 'published_parsed' in e:
entry.published_parsed = datetime.fromtimestamp(mktime(e.published_parsed)) #feed timestamp
if 'updated_parsed' in e:
entry.updated_parsed = datetime.fromtimestamp(mktime(e.updated_parsed)) #feed timestamp
if 'summary' in e:
entry.summary = e.summary
entry.save()
else:
print 'Entry with no Publication date: %s' % e
return HttpResponseRedirect( reverse('entries') )
示例2: post
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import content [as 别名]
def post(self):
"""
/api/item, POST, create item
表单字段: url, author, title, content
"""
p = Entry()
p.url = self.request.get('tUrl')
p.author = self.request.get('tAuthor')
p.title = self.request.get('tTitle')
p.content = self.request.get('tContent')
p.tags = self.request.get('tTags').split(',')
p.put(); # save
self.response.headers['Content-Type'] = 'application/json'
self.response.out.write('{ "success":true, "id":%s }' % p.key().id())
示例3: post
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import content [as 别名]
def post(self):
#表单字段: url, author, title, content, allow_sendto_kindle
bSendIt = self.request.get('bSendIt')
p = Entry()
p.url = self.request.get('tUrl')
p.author = self.request.get('tAuthor')
p.title = self.request.get('tTitle')
p.content = self.request.get('tContent')
p.tags = self.request.get('tTags').split(',')
p.put(); # save
#send to kindle
if bSendIt:
common.add_task_sendmail(p.key().id());
return self.redirect('/list/1')
示例4: autosave
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import content [as 别名]
def autosave(handler, route, params):
title = params.get("title", "")
content = params.get("content", "")
key = params.get("key", None)
user = handler.session.get("account", False)
if not title or not content:
return {"saved": False}
if not user:
return {"account": False, "saved": False}
if key:
draft = Entry.get_by_key_name(key)
if str(draft._author) != user:
raise Exception("You are not this article's author")
else:
key = str(time.time()).replace(".", "")
draft = Entry(key_name=key, author=db.Key(user))
draft.title = title
draft.content = content
draft.put()
return {"saved": key, "time": draft.isodate}