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


Python BlogPost.get_by_id方法代码示例

本文整理汇总了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
开发者ID:,项目名称:,代码行数:27,代码来源:

示例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,
        }
开发者ID:ashenwolf,项目名称:skoll-tech-portfolio,代码行数:9,代码来源:views.py

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

示例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)
开发者ID:ramuta,项目名称:homepage,代码行数:10,代码来源:blog.py

示例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,
        }
开发者ID:ashenwolf,项目名称:skoll-tech-portfolio,代码行数:13,代码来源:views_admin.py

示例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
    })
开发者ID:doctorMcbob,项目名称:wwf,代码行数:16,代码来源:views.py

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

示例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,
        }
开发者ID:ashenwolf,项目名称:skoll-tech-portfolio,代码行数:18,代码来源:views_admin.py

示例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)
开发者ID:,项目名称:,代码行数:43,代码来源:

示例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)
开发者ID:snarfed,项目名称:bridgy,代码行数:7,代码来源:test_superfeedr.py

示例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})
开发者ID:ramuta,项目名称:homepage,代码行数:5,代码来源:blog.py

示例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)
开发者ID:tantek,项目名称:bridgy,代码行数:6,代码来源:test_superfeedr.py


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