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


Python Entry.raw_body方法代码示例

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


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

示例1: save_entry

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import raw_body [as 别名]
def save_entry():
    """Save the entry (ajax)"""
    user = session["user"]
    entry_id = request.form["entry_id"]
    raw_body = request.form["raw_body"]

    assert user
    assert entry_id
    assert isinstance(entry_id, basestring)
    assert isinstance(raw_body, basestring)

    entry = Entry(entry_id, user.username)
    entry.raw_body = raw_body

    entry = entry.save()
    return json.dumps(entry.to_json())
开发者ID:pmn,项目名称:qi.io,代码行数:18,代码来源:website.py

示例2: sign_up

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import raw_body [as 别名]
def sign_up():
    """Register a user"""
    form = SignupForm()
    user = None

    if request.method == "POST" and form.validate():
        # Add the user
        username = request.form["username"]
        password = request.form["password"]

        if username and password:
            if db.get_user(username):
                # This username already exists
                flash("This username has already been reserved, please choose another")
                return render_template("signup.html", form=form, user=None)

            user = User(username)
            user.set_password(password)

            user.save()
            # Log the user in
            session["user"] = user

            # Create a new entry for the user so they have something to look at
            new_entry = Entry(None, user.username)
            new_entry.raw_body = """Double-click in this area or use the edit button to edit this entry!

Create tags by adding a "#" before a word, like this: #mytag
"""
            new_entry.save()

            logging.info("User created: {}".format(username))

            flash("Successfully registered. Welcome, {}!".format(username))
            return redirect(url_for("page"))
    return render_template("signup.html", form=form, user=user)
开发者ID:pmn,项目名称:qi.io,代码行数:38,代码来源:website.py


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