本文整理汇总了Python中models.BlogPost.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python BlogPost.get_by_id方法的具体用法?Python BlogPost.get_by_id怎么用?Python BlogPost.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.BlogPost
的用法示例。
在下文中一共展示了BlogPost.get_by_id方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import get_by_id [as 别名]
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
示例2: get
# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import get_by_id [as 别名]
def get(self, post_id):
post = BlogPost.get_by_id(long(post_id))
return {
"section": "blog",
"post": post,
}
示例3: get
# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import get_by_id [as 别名]
def get(self,blog,id):
post = BlogPost.get_by_id(int(id))
templ_val = {
'post': post,
'active_blogs':True,
'comments':post.comments.order('date')
}
self.render_to_response('post.html',templ_val)
示例4: post
# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import get_by_id [as 别名]
def post(self, blog_id):
blog = BlogPost.get_by_id(int(blog_id))
title = self.request.get("title")
slug = self.request.get("slug")
text = self.request.get("text")
if title and slug and text:
blog = BlogPost.update(blog_post=blog, title=title, slug=slug, text=text)
return self.redirect_to("blog-details", slug=blog.slug)
示例5: get
# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import get_by_id [as 别名]
def get(self, post_id, extra=""):
post = BlogPost.get_by_id(long(post_id))
form = BlogPostForm(obj = post)
return {
"admin_section": "admin-blog-posts",
"form": form,
"success": extra=="saved",
"upload_url": blobstore.create_upload_url(webapp2.uri_for('image-upload')),
"post": post,
}
示例6: postview
# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import get_by_id [as 别名]
def postview(request, session):
uri = request["uri"].split("/")
post_id = int(uri[-1])
try:
post = BlogPost.get_by_id(post_id, session)
title = post.title
text = post.text
except Exception as e:
print e.message
raise Exception("404 Not Found")
return render_html("post.html", context={
"title": title,
"text": text
})
示例7: post
# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import get_by_id [as 别名]
def post(self):
post = BlogPost.get_by_id(int(self.request.get('postid')))
c = Comment(
body = self.request.get('body'),
post = post,
author_name = self.getCurrentUserName()
)
c.put()
#post.comments_count += 1
post.put()
templ_vals = {
'comment': c
}
self.render_to_response('comment.html',templ_vals)
示例8: post
# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import get_by_id [as 别名]
def post(self, post_id, extra=""):
form = BlogPostForm(self.request.POST)
success = False
post = BlogPost.get_by_id(long(post_id))
if form.validate():
form.populate_obj(post)
post.save()
success = True
return {
"admin_section": "admin-blog-posts",
"form": form,
"success": success,
"post": post,
}
示例9: handleApost
# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import get_by_id [as 别名]
def handleApost(id):
posts=memcache.get(KEY)
tags=memcache.get(TAG)
categories=memcache.get(CATEGORY)
if not posts:
posts = BlogPost.all().order("-timestamp").fetch(20)
memcache.add(KEY,posts)
if not tags:
tags = Tag.all().fetch(20)
memcache.add(TAG,tags)
if not categories:
categories= Category.all().fetch(20)
memcache.add(CATEGORY,categories)
obj=BlogPost.get_by_id(int(id))
tagkeys=obj.tags
if request.method=="GET":
apost=APost(id=id)
data=apost.retrieve()
return jsonify(msg="OK",posts=data)
elif users.is_current_user_admin() and request.method=="DELETE":
apost=APost(id=id)
apost.delete()
return jsonify(msg="OK")
elif users.is_current_user_admin() and request.method=="PUT":
title=request.json['title']
body=request.json['body']
date=request.json['date']
category=request.json['category']
posttags=request.json['tags']
apost=APost(title,body,date,category,posttags,id)
(data,returnedTags)=apost.update()
return jsonify(msg="OK",tags=returnedTags,posts=data)
示例10: test_handle_feed_allows_bridgy_publish_links
# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import get_by_id [as 别名]
def test_handle_feed_allows_bridgy_publish_links(self):
item = {'permalinkUrl': 'A', 'content': 'a https://brid.gy/publish/facebook b'}
superfeedr.handle_feed(json.dumps({'items': [item]}), self.source)
self.assert_equals(['https://brid.gy/publish/facebook'],
BlogPost.get_by_id('A').unsent)
示例11: get
# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import get_by_id [as 别名]
def get(self, blog_id):
blog = BlogPost.get_by_id(int(blog_id))
return self.render_template("blog_post_edit.html", params={"blog": blog})
示例12: test_handle_feed_allows_bridgy_publish_links
# 需要导入模块: from models import BlogPost [as 别名]
# 或者: from models.BlogPost import get_by_id [as 别名]
def test_handle_feed_allows_bridgy_publish_links(self):
item = {"permalinkUrl": "A", "content": "a https://brid.gy/publish/facebook b"}
superfeedr.handle_feed(json.dumps({"items": [item]}), self.source)
self.assert_equals(["https://brid.gy/publish/facebook"], BlogPost.get_by_id("A").unsent)