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


Python Post.name方法代码示例

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


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

示例1: addPostToDatabase

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import name [as 别名]
def addPostToDatabase(thread):
    post = Post()
    post.name =  thread["data"]["title"]
    post.url =  "http://www.reddit.com" + thread["data"]["permalink"]
    post.upvotes =  thread["data"]["ups"]
    post.downs = thread["data"]["downs"]
    session.add(post)
    session.commit()
    return post
开发者ID:NSkelsey,项目名称:reddit_sweep,代码行数:11,代码来源:pages.py

示例2: add_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import name [as 别名]
def add_post(data, instance_id=""):
    if instance_id:
        post = Post.get_by_id(int(instance_id))
    else:
        post = Post()

    if data["name"]:
        post.name = data["name"]

    if data["email"]:
        post.email = data["email"]

    if data["twitter"]:
        post.twitter = data["twitter"]

    if data["facebook"]:
        post.facebook = data["facebook"]

    if data["phone"]:
        post.phone = data["phone"]

    if data["message"]:
        post.message = data["message"]

    if data["post_type"]:

        types = []
        for this_type in data["post_type"]:
            post_type = this_type.replace(" ", "_")
            types.append(post_type.upper())
        if post.post_type:
            for item in types:
                post.post_type.append(item)
        else:
            post.post_type = types
    else:
        post.post_type = ['NEED']

    if data["expiry"]:
        post.expiry = data["expiry"]

    if data["status"]:
        post.status = data["status"].upper()

    if data["location"]:
        post.location = data["location"]

    post.put()
    return post
开发者ID:albertpadin,项目名称:bangonph,代码行数:51,代码来源:functions.py

示例3: new_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import name [as 别名]
def new_post():
    if not g.site.domain == g.user:
        abort(403)

    p = Post()
    if request.method == "POST":
        reqfile = request.files.get("file")
        if reqfile:
            f = File()
            f.site = g.site.domain
            f.name = reqfile.filename
            f.content_type = reqfile.mimetype
            f.slug, f.content_length = save_file(reqfile, blog.config["UPLOAD_FOLDER"])
            f.save()

        import datetime

        p.site = g.site.domain
        p.name = request.form.get("name")
        p.created = datetime.datetime.utcnow()
        p.year = p.created.year
        p.month = p.created.month
        p.day = p.created.day
        slugs = [
            __j.slug
            for __j in Post.objects.filter(site=g.site.domain, year=p.year, month=p.month, day=p.day, slug=p.slug)
        ]
        counter = 1
        slug = slugify(p.name)
        __slug = slug
        while __slug in slugs:
            counter += 1
            __slug = "%s_%d" % (slug, counter)
        p.slug = __slug
        p.text = request.form.get("text")
        if reqfile:
            p.image_slug = f.slug
        p.save()
        return redirect(url_for("post", year=p.year, month=p.month, day=p.day, slug=p.slug))
    return render_template("edit_post.html", post=p)
开发者ID:sigurdga,项目名称:samklang,代码行数:42,代码来源:blog.py

示例4: add_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import name [as 别名]
def add_post(data, instance_id=""):
    if instance_id:
        post = Post.get_by_id(int(instance_id))
    else:
        post = Post()

    if data["name"]:
        post.name = data["name"]

    if data["email"]:
        post.email = data["email"]

    if data["twitter"]:
        post.twitter = data["twitter"]

    if data["facebook"]:
        post.facebook = data["facebook"]

    if data["phone"]:
        post.phone = data["phone"]

    if data["message"]:
        post.message = data["message"]

    if data["post_type"]:
        post.post_type = data["post_type"]

    if data["expiry"]:
        post.expiry = data["expiry"]

    if data["status"]:
        post.status = data["status"].upper()

    if data["location"]:
        post.location = data["location"]

    post.put()
    return post
开发者ID:rileonard15,项目名称:bangonph,代码行数:40,代码来源:functions.py

示例5: index

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import name [as 别名]
def index(request):
    if request.method == 'POST':
        name = request.user
        text = request.POST['text']
        cDate = datetime.datetime.now()
        
        post = Post(text=text)
        post.name = name
        post.cDate = cDate
        
        if name and text and cDate != "":
            post.save()
            return HttpResponseRedirect(reverse('comment.views.index'))
        else:
            error = "All fields are required to post a comment!"
            post = Post.objects.all().order_by(-cDate)[:100]
            return render_to_response('comment/comments.html', { 'Post' : post, 'Error' : error }, context_instance=RequestContext(request))

    post = Post.objects.all().order_by('-cDate')[:5]
    stuff = Context({
        'Post': post
    })
    return render_to_response('comment/comments.html', stuff, context_instance=RequestContext(request))
开发者ID:mando04,项目名称:Sampleblog,代码行数:25,代码来源:views.py

示例6: User

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import name [as 别名]
from models import User, Post

User.create(name='Amy', email='[email protected]')  # return an instance of User

User.create(User.name == 'Join', User.email == '[email protected]')

user = User(name='Mark', email='[email protected]')
user.save()

post = Post()
post.name = 'Hello World'
post.user_id = 1
post.save()
开发者ID:PeerXu,项目名称:CURD.py,代码行数:15,代码来源:create.py


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