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


Python Entry.content方法代码示例

本文整理汇总了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') )
开发者ID:juliangay,项目名称:ticker-tape,代码行数:55,代码来源:views.py

示例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())
开发者ID:tonychi,项目名称:readLater,代码行数:18,代码来源:api.py

示例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')
开发者ID:tonychi,项目名称:readLater,代码行数:19,代码来源:main.py

示例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}
开发者ID:michael-gillette,项目名称:GaeMVC,代码行数:22,代码来源:writer.py


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