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


Python Post.get_by_key_name方法代码示例

本文整理汇总了Python中models.Post.get_by_key_name方法的典型用法代码示例。如果您正苦于以下问题:Python Post.get_by_key_name方法的具体用法?Python Post.get_by_key_name怎么用?Python Post.get_by_key_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Post的用法示例。


在下文中一共展示了Post.get_by_key_name方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tnx

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_by_key_name [as 别名]
 def tnx():
     entity = Post.get_by_key_name(key_name)
     if entity is None:
         entity = Post(key_name=key_name, **kwds)
         entity.put()
         return (True, entity)
     return (False, entity)
开发者ID:4416,项目名称:hazel-cms,代码行数:9,代码来源:views.py

示例2: search

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_by_key_name [as 别名]
def search(user, query, type='and'):
    if type == 'phrase':
        ids = _phrase_search(user, query)
    else:
        ids = _and_search(user, query)
    #logging.info(ids)
    posts = Post.get_by_key_name(ids, parent=user)
    #logging.info(posts[0].message)
    return sorted(posts, key=operator.attrgetter('created_time'), reverse=True)
开发者ID:hideki,项目名称:locateweb,代码行数:11,代码来源:searcher.py

示例3: show

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_by_key_name [as 别名]
def show(request, key):
    prevent_cache = False
    post = Post.get_by_key_name('Published:%s' % key)
    if not post and users.is_current_user_admin():
        # admin might also try to retrieve the post by it's key!
        post = Post.get_by_key_name(key)
        prevent_cache = True
    if post:
        ns = NutSettings()
        template = ns.articles_layout
        if template:
            template = 'nut:layout/%s' % template
        else:
            template = 'app:articles/show.html'
        resp = render_template(template, post=post)
        resp.prevent_cache = prevent_cache
    else:
        resp = render_template('app/404.html')
        resp.prevent_cache = True
    return resp
开发者ID:4416,项目名称:hazel-cms,代码行数:22,代码来源:views.py

示例4: edit

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_by_key_name [as 别名]
def edit(request, key):
    post = Post.get_by_key_name(key)
    form = ArticleForm(request.form, obj=PostProxy(post), prefix='edit')
    status = False
    if request.method == 'POST' and form.validate():
        key_name, kwds = prepare(form)
#        kwds['html'] = render_jinja('cache_body.html', body=kwds['body'])
        if post.key().name() == key_name:
            post = update_entity(key_name, **kwds)
            status = 'Updated'
        else:
            kwds['author'] = users.get_current_user()
            created, entity = create_entity(key_name, **kwds)
            if not created:
                return Response('sorry, post with that pub_date and title'\
                                    + 'exists already')
            post.invalidate_cache()
            post.delete()
            post = entity
            status = 'Updated'
        post.invalidate_cache()
        if form.save.data:
            return redirect(url_for('nut:articles/list'), 301)
    return render_template('app:articles/form.html', form=form, post=post, status=status)
开发者ID:4416,项目名称:hazel-cms,代码行数:26,代码来源:views.py

示例5: delete

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import get_by_key_name [as 别名]
def delete(request, key):
    post = Post.get_by_key_name(key)
    if request.method == 'POST':
        post.delete()
        return redirect(url_for('nut:articles/list'), 301)
    return render_template('app:articles/post_confirm_delete.html', post=post)
开发者ID:4416,项目名称:hazel-cms,代码行数:8,代码来源:views.py


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