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


Python Article.get方法代码示例

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


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

示例1: article_delete

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import get [as 别名]
def article_delete(request, key):
    if not key:
        return redirect(article_list)
    if request.POST.get('confirmation') == 'yes':
        m = Article.get(key)
        if m: 
            m.delete()
            Article.get(key) # for refreshing purposes http://stackoverflow.com/questions/15773892/should-i-expect-stale-results-after-redirect-on-local-environment
    if request.POST.get('confirmation'):
        return redirect(article_list)
    return render_to_response("confirmation.html", {}, context_instance=RequestContext(request))      
开发者ID:rkrysinski,项目名称:gae-python-example,代码行数:13,代码来源:admin_views.py

示例2: article_add

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import get [as 别名]
def article_add(request):
    if request.method == 'POST':
        formset = ArticleForm(request.POST)
        if formset.is_valid():
            instance = formset.save()
            Article.get(instance.key())
            return redirect(article_list)
    else:
        formset = ArticleForm()
    return render_to_response("articles_add.html", {
                                    "formset": formset,
                              }, context_instance=RequestContext(request))  
开发者ID:rkrysinski,项目名称:gae-python-example,代码行数:14,代码来源:admin_views.py

示例3: createArticle

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import get [as 别名]
    def createArticle(self, request):
        """Create new Article object, returning ArticleForm/request."""
        
        for required in ['title', 'content']:
            if not getattr(request, required):
                raise endpoints.BadRequestException("Article '%s' field required" % required)

        # copy ArticleForm/ProtoRPC Message into dict
        data = {field.name: getattr(request, field.name) for field in request.all_fields()}

        if data['view'] == None:
            del data['view']
        else:
            data['view'] = str(data['view'])

        author = self._getAuthorFromUser()
        data['authorName'] = author.displayName

        article_id = Article.allocate_ids(size=1, parent=author.key)[0]
        article_key = ndb.Key(Article, article_id, parent=author.key)
        data['key'] = article_key

        # create Article
        article_key = Article(**data).put()

        # send email to author confirming creation of Article
        taskqueue.add(params={'email': author.mainEmail,
            'ArticleInfo': repr(request)},
            url='/tasks/send_confirmation_email'
        )

        return self._copyArticleToForm(article_key.get(), author=author)
开发者ID:dansalmo,项目名称:new-aca,代码行数:34,代码来源:aca.py

示例4: post

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import get [as 别名]
    def post(self):
        article = self.request.POST.get('id')
        instance = Article.get(article) if article else None

        data = ArticleForm(data=self.request.POST, instance=instance)
        if data.is_valid():
            entity = data.save(commit=False)
            if hasattr(self.request.POST.get('img'), 'file'):
                entity.img = Blob(self.request.POST.get('img').file.read())
            entity.put()
            self.redirect_to("new", message='Статья успешно сохранена!')
        else:
            self.response.out.write(render('templates/article.html', {'form': data}))
开发者ID:stachern,项目名称:bseu_news,代码行数:15,代码来源:article.py


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