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


Python Article.content方法代码示例

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


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

示例1: getArticles

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import content [as 别名]
def getArticles():
    articles = Article.query()
    if articles.count() == 0:
        hello = Article()
        hello.title = "Hello World"
        hello.content = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur, voluptatum. Provident accusamus sit, commodi corrupti illo, veniam possimus minima rerum itaque. Magni, beatae, facere."
        hello.put()
        bye = Article()
        bye.title = "Bye World"
        bye.content = "Iraqi PM Nouri Maliki steps aside, ending political deadlock in Baghdad as the government struggles against insurgents in the north."
        bye.put()
        del hello, bye
        articles = Article.query()
    return serialize(list(articles.order(Article.date).fetch(10)))
开发者ID:blogmv,项目名称:backend-python-flask,代码行数:16,代码来源:blogmv.py

示例2: article_save

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import content [as 别名]
def article_save():
    mid = request.form.get('id')
    title = request.form.get('title', '')
    content = request.form.get('content', '')
    
    if (mid == None or mid == ''):
        article = Article(title=title, content=content, add_time=datetime.now(), edit_time=datetime.now())
        for cid in request.form.getlist("tags"):
            article.tags.add(Tag.query.get(cid))
        for cid in request.form.getlist("categories"):
            article.categories.add(Category.query.get(cid))
        db.session.add(article)
    else:
        article = Article.query.get(int(mid))
        article.title=title
        article.content=content
        article.edit_time=datetime.now()
        article.categories.clear()
        article.tags.clear()
        for cid in request.form.getlist("tags"):
            article.tags.add(Tag.query.get(cid))
        for cid in request.form.getlist("categories"):
            article.categories.add(Category.query.get(cid))
            
    db.session.commit()
    flash('保存成功!', 'success')
    return redirect(url_for('.article',page=1))
开发者ID:x20080406,项目名称:theblog,代码行数:29,代码来源:controllers.py

示例3: create

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import content [as 别名]
def create(request):
    """ Create a new blog article
    """
    # instantiate a new instance and populate fields from form data
    article = Article()
    article.title = request.POST.get("title", None)
    article.author = request.user
    article.content = request.POST.get("content", None)
    # save new article, get updated articles list and user
    article.save()
    articles = Article.objects.all()
    user = request.user
    # render index page with updated data
    return render(request, "index.html", {"testvar": "Test String 2!", "articles": articles, "user":user})
开发者ID:valencra,项目名称:django-blog,代码行数:16,代码来源:views.py

示例4: put

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import content [as 别名]
 def put(self):
     rbody = self.request.body.split('&')
     rbody = dict([(p.split('=')[0], p.split('=')[1]) for p in rbody])
     tid = rbody['tid']
     article = Article.query.filter_by(id=tid).first()
     if not article:
         article = Article() 
     title = rbody['title']
     content = rbody['content']
     tag = rbody['tag']
     try:
         article.title = title
         article.content = content
         article.tag = tag
         db.session.add(article)
         db.session.flush()
         db.session.commit()
     except Exception as e:
         raise tornado.web.HTTPError(500, 'edit article error')
     self.write('ok')
开发者ID:martinruirui,项目名称:blog,代码行数:22,代码来源:handlers.py

示例5: post

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import content [as 别名]
    def post(self):
        til = self.get_argument('title', None)
        content = self.get_argument('content', None)
        uid = self.get_argument('uid', None)
        tag = self.get_argument('tag', '')
        cat = self.get_argument('cat_id', 0)

        if not til or not content or not uid:
            raise tornado.web.HTTPError(400, 'parameters invalid')
        try:
            article = Article()
            article.title = til
            article.content = content
            article.user_id = int(uid)
            article.tag = tag
            article.cat_id = int(cat)
            db.session.add(article)
            db.session.flush()
            db.session.commit()
        except Exception as e:
            raise tornado.web.HTTPError(500, 'add article error')
        self.write('ok')
开发者ID:martinruirui,项目名称:blog,代码行数:24,代码来源:handlers.py

示例6: post

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import content [as 别名]
    def post(self):
        from markdown2 import markdown

        title = self.request.get('title')
        content = self.request.get('content')
        slug_title = self.request.get('slug_title')
        section_type = self.request.get('section_type')

        content_html = markdown(content)

        #user = users.get_current_user()

        article = Article()
        article.title = title
        article.slug_title = slug_title
        article.content = content
        article.section_type = section_type
        #article.author = user
        article.content_html = content_html
        article.is_draft = True
        article.put()

        self.response.out.write(article.to_json('title', 'section_type', 'is_draft', 'is_deleted', 'is_active', 'is_starred'))
开发者ID:spaceone,项目名称:mils-secure,代码行数:25,代码来源:api.py

示例7: post

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import content [as 别名]
    def post(self, request, *args, **kwargs):
        if request.session.get('account_id', None) is None:
            return HttpResponseRedirect('/account/login')

        d = request.POST.dict()
        i = Article()
        account_id = request.session['account_id']
        i.account_id = str(account_id)
        i.username = request.session['username']
       
        tag = d.get('tag', None)   
        if tag != '':
            if tag[-1] == ';':
                tag = tag[:-1]
            i.tag = tag.split(';')
        i.category = int(d['category'])
        i.head_image = d.get('head_image', None)
        i.title = d['title']
        i.content = d['content'] 
        i.status = 1
        i.save()

        return HttpResponseRedirect('/blog')
开发者ID:waynetian,项目名称:guqintai,代码行数:25,代码来源:views.py

示例8: edit_article

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import content [as 别名]
def edit_article(request, id=None):
    data = {}
    article = Article()
    
    if request.method == "POST":
        form = ArticleForm(request.POST,instance=article) # A form bound to the POST data
        if form.is_valid():
            article.title = form.cleaned_data['title']
            article.content = form.cleaned_data['content']
            article.author = User.objects.get(pk=request.user.id)

            article.save()
            return HttpResponseRedirect('/blog/view/%s' % article.id)
    elif request.method == "GET":
        if id != None:
            article = Article.objects.get(pk=id)
        form = ArticleForm(instance=article)
    else:
        raise Http404

    data['form'] = form
    print form.errors
    return render_to_response(BLOG_TEMPLATE + 'edit.html', data, context_instance=RequestContext(request))
开发者ID:cyrilsx,项目名称:smart_cms,代码行数:25,代码来源:views.py


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