本文整理汇总了Python中redwind.models.Post.content方法的典型用法代码示例。如果您正苦于以下问题:Python Post.content方法的具体用法?Python Post.content怎么用?Python Post.content使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redwind.models.Post
的用法示例。
在下文中一共展示了Post.content方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_send_wms
# 需要导入模块: from redwind.models import Post [as 别名]
# 或者: from redwind.models.Post import content [as 别名]
def test_send_wms(client, mocker):
getter = mocker.patch('requests.get')
poster = mocker.patch('requests.post')
urlopen = mocker.patch('urllib.request.urlopen')
post = Post('note')
post.content = 'This note links to [wikipedia](https://en.wikipedia.org/wiki/Webmention)'
post.content_html = 'This note links to <a href="https://en.wikipedia.org/wiki/Webmention">wikipedia</a>'
post.path = '2014/11/wm-sender-test'
db.session.add(post)
db.session.commit()
urlopen.return_value = FakeUrlOpen(
info=FakeUrlMetadata(content_type='text/html', content_length=256))
getter.return_value = FakeResponse(text="""<!DOCTYPE html>
<html>
<link rel="webmention" href="https://en.wikipedia.org/endpoint">
</html>""")
wm_sender.do_send_webmentions(post.id)
getter.assert_called_with('https://en.wikipedia.org/wiki/Webmention')
poster.assert_called_with('https://en.wikipedia.org/endpoint', data={
'source': post.permalink,
'target': 'https://en.wikipedia.org/wiki/Webmention',
}, headers={
'content-type': 'application/x-www-form-urlencoded',
'accept': 'application/json',
})
示例2: source_post
# 需要导入模块: from redwind.models import Post [as 别名]
# 或者: from redwind.models.Post import content [as 别名]
def source_post(app, db):
post = Post('note')
post.content = 'This note links to [wikipedia](https://en.wikipedia.org/wiki/Webmention)'
post.content_html = 'This note links to <a href="https://en.wikipedia.org/wiki/Webmention">wikipedia</a>'
post.path = '2014/11/wm-sender-test'
db.session.add(post)
db.session.commit()
return post
示例3: new_post
# 需要导入模块: from redwind.models import Post [as 别名]
# 或者: from redwind.models.Post import content [as 别名]
def new_post(type):
post = Post(type)
post.published = post.updated = datetime.datetime.utcnow()
post.content = ''
if type == 'reply':
in_reply_to = request.args.get('url')
if in_reply_to:
post.in_reply_to = [in_reply_to]
# post.reply_contexts = [contexts.create_context(in_reply_to)]
elif type == 'share':
repost_of = request.args.get('url')
if repost_of:
post.repost_of = [repost_of]
# post.repost_contexts = [contexts.create_context(repost_of)]
elif type == 'like':
like_of = request.args.get('url')
if like_of:
post.like_of = [like_of]
# post.like_contexts = [contexts.create_context(like_of)]
elif type == 'bookmark':
bookmark_of = request.args.get('url')
if bookmark_of:
post.bookmark_of = [bookmark_of]
# post.bookmark_contexts = [contexts.create_context(bookmark_of)]
post.content = request.args.get('content')
button_text = {
'publish': 'Publish',
'publish_quietly': 'Publish Quietly',
'publish+tweet': 'Publish & Tweet',
'save_draft': 'Save as Draft',
}
if type == 'event':
venues = Venue.query.order_by(Venue.name).all()
else:
venues = []
return render_template('admin/edit_' + type + '.jinja2',
edit_type='new', post=post,
tags=get_tags(), top_tags=get_top_tags(20),
button_text=button_text, venues=venues)
示例4: new_post
# 需要导入模块: from redwind.models import Post [as 别名]
# 或者: from redwind.models.Post import content [as 别名]
def new_post(type):
if type not in util.POST_TYPES:
abort(404)
post = Post(type)
post.published = post.updated = datetime.datetime.utcnow()
post.content = ''
if type == 'reply':
in_reply_to = request.args.get('url')
if in_reply_to:
post.in_reply_to = [in_reply_to]
elif type == 'share':
repost_of = request.args.get('url')
if repost_of:
post.repost_of = [repost_of]
elif type == 'like':
like_of = request.args.get('url')
if like_of:
post.like_of = [like_of]
elif type == 'bookmark':
bookmark_of = request.args.get('url')
if bookmark_of:
post.bookmark_of = [bookmark_of]
post.content = request.args.get('content')
button_text = {
'publish': 'Publish',
'publish_quietly': 'Publish Quietly',
'publish+tweet': 'Publish & Tweet',
'save_draft': 'Save as Draft',
}
venues = Venue.query.order_by(Venue.name).all()
return render_template('admin/edit_' + type + '.jinja2',
edit_type='new', post=post,
tags=get_tags(), top_tags=get_top_tags(20),
people=get_contact_nicks(),
button_text=button_text, venues=venues)