本文整理汇总了Python中models.BlogPost类的典型用法代码示例。如果您正苦于以下问题:Python BlogPost类的具体用法?Python BlogPost怎么用?Python BlogPost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BlogPost类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self,title=None,body=None,date=None,category=None,posttags=None,id=None):
Action.__init__(self)
if id==None:
self.title=title
self.body=body
self.date=date
self.postcategory=category
self.posttags=posttags
elif title==None:
self.obj =BlogPost.get_by_id(int(id))
self.id = self.obj.key().id()
self.post_tags_keys = self.obj.tags
else:
self.obj = BlogPost.get_by_id(int(id))
self.id = self.obj.key().id()
self.post_tags_keys = self.obj.tags
self.title=title
self.body=body
self.date=date
self.postcategory=category
self.posttags=posttags
开发者ID:,项目名称:,代码行数:25,代码来源:
示例2: post
def post(self):
title = self.request.get("title")
slug = self.request.get("slug")
text = self.request.get("text")
if title and slug and text:
BlogPost.create(title, slug, text)
return self.redirect_to("main")
开发者ID:ramuta,项目名称:homepage,代码行数:7,代码来源:blog.py
示例3: add_post
def add_post(request):
if request.method == 'POST':
form = BlogPostForm(request.POST)
if form.is_valid():
new_post = BlogPost(
title=form.cleaned_data['title'],
content=form.cleaned_data['content'],
published=True,
author=request.user
)
new_post.save()
return redirect('view_posts', post_id=new_post.id)
else:
form = BlogPostForm()
return render(
request,
'add_post.html',
{
'form': form,
}
)
开发者ID:fscherf,项目名称:django_workshop,代码行数:25,代码来源:views.py
示例4: add_post
def add_post():
title = request.form.get('title', None)
content = request.form.get('content', None)
if title and content:
if len(str(title))==10 and len(str(content))==6:
BlogPost.create(title, content)
return redirect(url_for('all_posts'))
return render_template('new_post.html', error='Username and Password are required')
开发者ID:ListFranz,项目名称:flask-and-websocket,代码行数:8,代码来源:views.py
示例5: create_blog_post
def create_blog_post(title, blurb, content):
published = datetime.now() + timedelta(days=-random.randint(1, 50))
p = BlogPost(title=title, blurb=blurb, content=content, published=published)
p.put()
for i in range(0, random.randint(0, 5)):
random_comment(p)
开发者ID:Docalytics,项目名称:app-engine-datastore-migrations,代码行数:8,代码来源:bootstrap.py
示例6: post
def post(self):
form = BlogPostForm(self.request.POST)
if form.validate():
post = BlogPost(**form.data)
post.save()
self.redirect_to("admin-blog-post-edit-extra", post_id = post.key().id(), extra="saved")
return {
"admin_section": "admin-blog-posts-new",
"form": form,
}
开发者ID:ashenwolf,项目名称:skoll-tech-portfolio,代码行数:12,代码来源:views_admin.py
示例7: post
def post(self):
subject = self.request.get("subject")
content = self.request.get("content")
if subject and content:
newpost = BlogPost(subject=subject, content=content)
key = newpost.put()
memcache.set("front_page", None)
self.redirect("/unit3/blog/%s" % key.id())
else:
self.write(
blog_post_form,
{"subject": subject, "content": content, "error": "Both subject and content are required."},
)
开发者ID:jadinvt,项目名称:gapengine-sbox,代码行数:13,代码来源:blog.py
示例8: edit_post
def edit_post(id):
form = PostForm()
if users.is_current_user_admin() and form.validate_on_submit():
tags = Tags()
categories = Categories()
updating_post = BlogPost.get(int(id))
title = request.json['title']
body = request.json['body']
raw_category = request.json['category']
editing_tags = request.json['tags']
raw_summary = request.json['summary']
tags_keys = tags.update(editing_tags, updating_post)
category_key = categories.update(raw_category, updating_post.category)
updating_post.edit(title, body, datetime.now(), tags_keys,
category_key, raw_summary, raw_answers=request.json['answers'])
return jsonify(updating_post.to_json()) # dangerous
开发者ID:aarsakian,项目名称:blog,代码行数:25,代码来源:views.py
示例9: get_post
def get_post(id):
if users.is_current_user_admin():
asked_post = BlogPost.get(id)
return jsonify(asked_post.to_json()) # dangerous
else:
return jsonify({})
开发者ID:aarsakian,项目名称:blog,代码行数:7,代码来源:views.py
示例10: get
def get(self,page):
posts = BlogPost.all().order('-pub_date').fetch(limit=10)
self.templ_vals.update({
'url':users.create_logout_url("/"),
'posts':posts,
})
self.render_to_response('index.html',self.templ_vals)
开发者ID:yanzay,项目名称:pagankolo,代码行数:7,代码来源:main.py
示例11: _blog_fetch_callback
def _blog_fetch_callback(self, rpc):
content = rpc.get_result().content
d = feedparser.parse(StringIO(content))
s = Signatures.get_single()
signatures_and_times = dict(zip(s.hashes, s.times))
posts = []
tags_entity = Tags.get_single()
tags = set(tags_entity.available)
for entry in d['entries']:
blog_post = BlogPost.blog_post_from_feed_entry(entry)
signature_time = signatures_and_times.get(blog_post.signature)
if signature_time:
signature_time = datetime.datetime.fromtimestamp(signature_time).strftime('%m/%d/%Y %H:%M')
posts.append((blog_post, signature_time))
for tag in blog_post.tags:
tags.add(tag.lower())
template_values = {"posts":posts}
tags_entity.available = list(tags)
tags_entity.save()
template = jinja_environment.get_template('moderate.html')
self.response.out.write(template.render(template_values))
开发者ID:darvin,项目名称:moderated-feed-gae-server,代码行数:28,代码来源:admin.py
示例12: test_subscribe
def test_subscribe(self):
expected = {
"hub.mode": "subscribe",
"hub.topic": "fake feed url",
"hub.callback": "http://localhost/fake/notify/foo.com",
"format": "json",
"retrieve": "true",
}
item_a = {"permalinkUrl": "A", "content": "a http://a.com a"}
item_b = {"permalinkUrl": "B", "summary": "b http://b.com b"}
feed = json.dumps({"items": [item_a, {}, item_b]})
self.expect_requests_post(superfeedr.PUSH_API_URL, feed, data=expected, auth=mox.IgnoreArg())
self.mox.ReplayAll()
superfeedr.subscribe(self.source, self.handler)
posts = list(BlogPost.query())
self.assert_entities_equal(
[
BlogPost(id="A", source=self.source.key, feed_item=item_a, unsent=["http://a.com"]),
BlogPost(id="B", source=self.source.key, feed_item=item_b, unsent=["http://b.com"]),
],
posts,
ignore=("created", "updated"),
)
tasks = self.taskqueue_stub.GetTasks("propagate-blogpost")
self.assert_equals(
[{"key": posts[0].key.urlsafe()}, {"key": posts[1].key.urlsafe()}],
[testutil.get_task_params(t) for t in tasks],
)
开发者ID:tantek,项目名称:bridgy,代码行数:31,代码来源:test_superfeedr.py
示例13: assert_blogposts
def assert_blogposts(self, expected):
got = list(BlogPost.query())
self.assert_entities_equal(expected, got, ignore=('created', 'updated'))
tasks = self.taskqueue_stub.GetTasks('propagate-blogpost')
self.assert_equals([{'key': post.key.urlsafe()} for post in expected],
[testutil.get_task_params(t) for t in tasks])
开发者ID:LennonFlores,项目名称:bridgy,代码行数:7,代码来源:test_superfeedr.py
示例14: get
def get(self, post_id):
post = BlogPost.get_by_id(long(post_id))
return {
"section": "blog",
"post": post,
}
开发者ID:ashenwolf,项目名称:skoll-tech-portfolio,代码行数:7,代码来源:views.py
示例15: test_subscribe
def test_subscribe(self):
expected = {
'hub.mode': 'subscribe',
'hub.topic': 'fake feed url',
'hub.callback': 'http://localhost/fake/notify/foo.com',
'format': 'json',
'retrieve': 'true',
}
item_a = {'permalinkUrl': 'A', 'content': 'a http://a.com a'}
item_b = {'permalinkUrl': 'B', 'summary': 'b http://b.com b'}
feed = json.dumps({'items': [item_a, {}, item_b]})
self.expect_requests_post(superfeedr.PUSH_API_URL, feed,
data=expected, auth=mox.IgnoreArg())
self.mox.ReplayAll()
superfeedr.subscribe(self.source, self.handler)
posts = list(BlogPost.query())
self.assert_entities_equal(
[BlogPost(id='A', source=self.source.key, feed_item=item_a,
unsent=['http://a.com']),
BlogPost(id='B', source=self.source.key, feed_item=item_b,
unsent=['http://b.com']),
], posts,
ignore=('created', 'updated'))
tasks = self.taskqueue_stub.GetTasks('propagate-blogpost')
self.assert_equals([{'key': posts[0].key.urlsafe()},
{'key': posts[1].key.urlsafe()}],
[testutil.get_task_params(t) for t in tasks])
开发者ID:sanduhrs,项目名称:bridgy,代码行数:30,代码来源:superfeedr_test.py
示例16: get
def get(self):
posts = BlogPost.all().order("-date_created")
return {
"admin_section": "admin-blog-posts",
"posts": posts,
}
开发者ID:ashenwolf,项目名称:skoll-tech-portfolio,代码行数:7,代码来源:views_admin.py
示例17: test_label
def test_label(self):
for feed_item in None, {}:
bp = BlogPost(id='x')
bp.put()
self.assertEquals('BlogPost x [no url]', bp.label())
bp = BlogPost(id='x', feed_item={'permalinkUrl': 'http://perma/link'})
bp.put()
self.assertEquals('BlogPost x http://perma/link', bp.label())
开发者ID:sanduhrs,项目名称:bridgy,代码行数:9,代码来源:models_test.py
示例18: get
def get(self, **kwargs):
language = self.get_locale()
posts = BlogPost.get_latest_posts(10, language=language)
context = {
'posts': posts,
'language': language,
}
return self.render_response('blog/index.html', **context)
开发者ID:frankk00,项目名称:gae-shop,代码行数:8,代码来源:handlers.py
示例19: getrecentposts
def getrecentposts(limit=5):
""" Get html for the [num] most recent posts.
Return a list of (title, html) tuples. """
q = BlogPost.all()
q.order('post_date')
posts = [(post.title, post.html) for post in q.run(limit=limit)]
return posts
开发者ID:rlmv,项目名称:mysite,代码行数:8,代码来源:db.py
示例20: refetch
def refetch(self):
self.posts =BlogPost.all().order('-timestamp')
memcache.add(KEY,self.posts)
self.tags = Tag.all()
memcache.add(TAG,self.tags)
self.categories= Category.all()
memcache.add(CATEGORY,self.categories)
createIndex(self.posts)
开发者ID:,项目名称:,代码行数:8,代码来源:
注:本文中的models.BlogPost类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论