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


Python Post.body方法代码示例

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


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

示例1: publish

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import body [as 别名]
def publish(user_id):
    form = PublishBlogForm()
    posts = Post()
    if form.validate_on_submit():
        blog_body = request.form.get("body")
        if not len(strip(blog_body)):
            flash("The content is necessray!")
            return redirect(url_for("publish", user_id=user_id))
        posts.body = blog_body
        posts.timestamp = datetime.datetime.now()
        posts.user_id = user_id

        try:
            db.session.add(posts)
            db.session.commit()
        except:
            flash("Database error!")
            return redirect(url_for("publish", user_id=user_id))

        flash("Publish Successful!", "success")
        return redirect(url_for("publish", user_id=user_id))

    return render_template(
        "publish.html",
        form=form)
开发者ID:yaoice,项目名称:flask-micblog,代码行数:27,代码来源:views.py

示例2: convert_posts

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import body [as 别名]
    def convert_posts(self, board_id=181):
        start_time = time.time()
        cursor = connection.cursor()
        cursor.execute("SELECT * FROM smf_messages WHERE id_board=%d ORDER BY id_msg ASC" % board_id)
        rows = cursor.fetchall()
        for row in rows:
            try: 
                try:
                    profile = Profile.objects.get(old_user_id=row[4])
                except Profile.DoesNotExist, e:
                    if not row[4] == 0:
                        print "Profile does not exist for %s" % (row[4])
                    profile = None

                try: 
                    topic = Topic.objects.get(old_topic_id=row[1])
                except Topic.DoesNotExist, e:
                    print "Topic %s does not exist" % (row[1])

                post = Post()
                post.topic          = topic
                post.old_post_id    = row[0]
                if profile == None:
                    post.user           = None
                else:
                    post.user           = profile.user
                post.legacy_username= row[7]
                post.created        = self.fix_epoch(row[3])
                post.updated        = self.fix_epoch(row[11])
                post.subject        = row[6]
                post.body           = self.clean(row[13])
                post.body_html      = self.markup(self.clean(row[13]))
                post.user_ip        = row[9]
                post.save()
                post.topic.save()
开发者ID:bmelton,项目名称:briskforum,代码行数:37,代码来源:convert_from_smf.py

示例3: _record_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import body [as 别名]
 def _record_post(self, bin, use_get=False):
     post = Post(bin=bin, remote_addr=self.request.remote_addr)
     post.headers        = dict(self.request.headers)
     try:
         post.body           = self.request.body
     except UnicodeDecodeError:
         #post.body_binary    = self.request.body
         pass
     post.query_string   = self.request.query_string
     post.form_data = []
     data_source = self.request.GET if use_get else self.request.POST
     post.size = len(post.body) if post.body else 0
     for k,v in data_source.items():
         if isinstance(v, FieldStorage):
             file_body = v.file.read()
             post.form_data.append([k, {
                 'file_name': v.filename,
                 'file_extension': v.filename.split('.')[-1],
                 'file_digest': hashlib.md5(file_body).hexdigest(),
                 'file_size': round(len(file_body) / 1024.0, 1),
             }])
             post.size += len(file_body)
         else:
             post.form_data.append([k,v])
     post.put()
开发者ID:bholtsclaw,项目名称:postbin,代码行数:27,代码来源:bin.py

示例4: publishs

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import body [as 别名]
def publishs(user_id):

    form = PublishBlogForm()

    if form.validate_on_submit():
        post_title = request.form.get("title")
        post_body = request.form.get("body")
        if not len(strip(post_body)) or not len(strip(post_title)):
            flash("不能提交空内容!")
            return redirect(url_for("publish", user_id=user_id))

        post = Post()
        post.body = post_body
        post.title = post_title
        post.timestamp = datetime.datetime.now()
        post.user_id = user_id


        try:
            db.session.add(post)
            db.session.commit()
        except:
            flash("DataBase error!")
            return redirect(url_for("publish", user_id=user_id))

        return redirect(url_for("user", user_id=user_id))

    return render_template(
        "publish.html",
        form = form)
开发者ID:wagt679,项目名称:xingblog,代码行数:32,代码来源:views.py

示例5: create

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import body [as 别名]
def create(request):
    if request.method == "POST":
        post = Post()
        post.title = request.POST.get("title")
        post.body = request.POST.get("body")
        post.save()
        return redirect("home")
    return render(request, "create.html")
开发者ID:ModSoftio,项目名称:djangoWorkshopRlug,代码行数:10,代码来源:views.py

示例6: _record_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import body [as 别名]
 def _record_post(self, bin, use_get=False):
     post = Post(bin=bin, remote_addr=self.request.remote_addr)
     post.headers        = dict(self.request.headers)
     post.body           = self.request.body
     post.query_string   = self.request.query_string
     if use_get:
         data_source = self.request.GET
     else:
         data_source = self.request.POST
     post.form_data      = [[k,v] for k,v in data_source.items()]
     post.put()
开发者ID:TimothyFitz,项目名称:postbin,代码行数:13,代码来源:bin.py

示例7: marks

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import body [as 别名]
def marks(request):
	form = Post()
	if request.method == 'POST': # If the form has been submitted...
		form.title = request.POST['title']
		form.body = request.POST['body']
		form.lon = float(request.POST['lon'])
		form.lat = float(request.POST['lat'])
		form.img = request.FILES.get('file', False)
		form.user = request.user
		form.save()
	return redirect('/')
开发者ID:wendiewang,项目名称:geonote,代码行数:13,代码来源:views.py

示例8: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import body [as 别名]
 def post(self):
     bin = self._get_bin()
     post = Post(bin=bin, remote_addr=self.request.remote_addr)
     post.headers        = dict(self.request.headers)
     post.body           = self.request.body
     post.query_string   = self.request.query_string
     post.form_data      = [[k,v] for k,v in self.request.POST.items()]
     post.put()
     if 'http://' in self.request.query_string:
         urlfetch.fetch(url=self.request.query_string.replace('http://', 'http://hookah.webhooks.org/'),
                         payload=urllib.urlencode(self.request.POST.items()), method='POST')
     self.redirect('/%s' % bin.name)
开发者ID:dustin,项目名称:postbin,代码行数:14,代码来源:bin.py

示例9: write_process

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import body [as 别名]
def write_process():
    if not session['logged_in']:
        return redirect(url_for('index'))
    u = User.query.filter_by(email=session['user_name']).first()
    p = Post()
    p.title = request.form['post_title']
    p.body = request.form['post_body']
    p.timestamp = datetime.datetime.utcnow()
    p.user_id = u.id
    db.session.add(p)
    db.session.commit()
    return redirect(url_for('index'))
开发者ID:rwdxll,项目名称:flask_blog,代码行数:14,代码来源:controllers.py

示例10: build_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import body [as 别名]
    def build_post(self,form,user):
 #       print 'after validate'
 #       print 'Logged in as %s' % user
        u = UserDT()
        u.first_name = user
        u.last_name = "b"
        u.email =  user + "@here.com"
        p = Post()
        p.title = form.title.data
        p.body = form.content.data
        p.creator = u
        print ' post - post build '
        return p
开发者ID:sheng01,项目名称:DuluthKids.Net,代码行数:15,代码来源:helper.py

示例11: make_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import body [as 别名]
def make_post(parent, header, content, commit=True, level=1):
    author_link = header.find('span', 'avatarusername').find('a')
    author = make_author(author_link)

    indent = ' ' * (level * 2)
    print '%s- Adding post by %s' % (indent, author)

    created_at = parse_post_date(author_link.parent.nextSibling)

    # gather up content elements
    els = iter(content) if content else sibs(header)
    def is_body(el):
        return el.name != 'pre' if isinstance(el, Tag) else True
    body = u'\n'.join(imap(unicode, takewhile(is_body, els)))

    post = Post.all()\
        .filter('papa =', parent)\
        .filter('author =', author)\
        .filter('created_at =', created_at)\
        .get()
    if post is None:
        post = Post(papa=parent, author=author,
                    created_at=created_at, tags=['Reply'])
    post.body = clean_body(body)

    to_put = [post]

    if content:
        children = content.find('div', style='padding: 5px 0 0 40px;')
    else:
        children = None

    if children:
        to_put = []
        post.put()
        headers = children.findAll('div', 'commentheader', recursive=False)
        if headers:
            print '%s  (found %s child post(s))' % (indent, len(headers))
        for header in headers:
            to_put.extend(make_post(post, header, None, level=level+1))

    if commit:
        db.put(to_put)

    return to_put
开发者ID:mccutchen,项目名称:wongthesis,代码行数:47,代码来源:importer.py

示例12: save

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import body [as 别名]
 def save(cls, request: Request, *args, **kwargs):
     """ Метод для сохранения поста
     :param request:
     :param kwargs:
     :return:
     """
     if request.get("id", False):
         post = blog.get_post(request.get("id"))
     else:
         post = Post()
     post.title = request.get("title")
     post.short = request.get("short")
     post.imgs = request.get("imgs", [])
     post.body = request.get("body", "")
     post.tags = request.get("tags", [])
     post.category = request.get("category", None)
     post.draft = request.get("draft", True)
     post.author_id = request.get("author_id", False)
     post.author_name = request.get("author_name", False)
     post.source = request.get("source", False)
     return {"post_id": post.save()}
开发者ID:ayurjev,项目名称:z9blog-api,代码行数:23,代码来源:controllers.py

示例13: build_thread

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import body [as 别名]
    def build_thread(self,form,user):
        print 'after validate'
#        print 'Logged in as %s' % user
        u = UserDT()
        u.first_name = user
        u.last_name = "b"
        u.email =  user + "@here.com"
        p = Post()
        p.title = "thread description"
        p.body = form.content.data
        p.creator = u
        print ' post - post build '
        pe = PostArrayEl()
        pe.key="1"
        pe.post=p
        t = Thread()
        t.title = form.name.data
        t.creator = u
        t.posts.append(pe)
        print ' thread - post build '
        t.postcnt=1
        return t
开发者ID:sheng01,项目名称:DuluthKids.Net,代码行数:24,代码来源:helper.py


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