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


Python User.save方法代码示例

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


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

示例1: post

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import save [as 别名]
    def post(self):
        # Get user information from POST request
        # fb_id = request.form.get('facebook_id')
        # name = request.form.get('name')
        fb_id = request.json.get('facebook_id')
        name = request.json.get('name')
        friends = request.json.get('friends')

        if not fb_id or not name:
            return {'status': 'fail', 'message': 'Please specify facebook id and name.'}

        # Create a User object
        user = User()
        user.facebook_id = fb_id
        user.name = name

        for f in friends:
            friend = Friend()
            friend.facebook_id = f.get('facebook_id')
            friend.name = f.get('name')
            user.friends.append(friend)

        # Connect to Face API
        response = requests.post(
            'https://api.projectoxford.ai/face/v1.0/persongroups/{}/persons'.format(persongroups_id),
            json={
                'name': fb_id,
                'userData': name
            },
            headers={
                'Ocp-Apim-Subscription-Key': sub_key
            }
        )

        response_json = response.json()
        if response_json.get('error'):
            return {'status': 'fail', 'message': response_json.get('error')}

        user.person_id = response_json.get('personId')

        user.save()

        # Return user information
        return {'status': 'success'}
开发者ID:akaraspt,项目名称:hacklondon2016,代码行数:46,代码来源:api.py

示例2: signup

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import save [as 别名]
def signup():
    if current_user.is_authenticated():
        return redirect(url_for('user.index'))

    loginForm = LoginForm()
    form = SignupForm(next=request.args.get('next'))

    if form.validate_on_submit():
        user = User()
        user.email = form.email.data.strip()
        user.name = form.name.data.strip()
        user.password = form.password.data
        user.save()

        if login_user(user):
            return redirect(form.next.data or url_for('users.index'))

    return render_template('frontend/login.html',
                           loginForm=loginForm,
                           signupForm=form)
开发者ID:g13013,项目名称:dzlibs,代码行数:22,代码来源:views.py

示例3: create_profile

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import save [as 别名]
def create_profile():
    if current_user.is_authenticated():
        return redirect(url_for('users.index'))

    form = CreateProfileForm()

    if form.validate_on_submit():
        user = User()
        user.email = form.email.data.strip()
        user.password = form.password.data
        user.github_id = session['github_id']
        user.name = session['name']
        user.github_username = session['github_username']
        user.oauth_token = session['oauth_token']
        user.location = session['location']
        user.save()

        if login_user(user):
            flash(_("Logged in"), 'success')

        return redirect(url_for('users.index'))

    return render_template('frontend/create_profile.html',
                           form=form)
开发者ID:g13013,项目名称:dzlibs,代码行数:26,代码来源:views.py

示例4: User

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import save [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Initial setup file"""
import  settings
from users import User

# add admin user
admin = User(settings.ADMIN, settings.ADMIN_PASSWORD, is_admin=True)
admin.save()



开发者ID:vihtinsky,项目名称:planninggame,代码行数:11,代码来源:setup.py

示例5: User

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import save [as 别名]
from mlab import *
from users import User
import mongoengine
from util import *

if __name__ == "__main__":
    db = mongoengine.connect(db_name,
                             host=host, port=port, username=user_name, password=password)
    user = User(user_name = "admin", password="admin")
    user.save()
    db.close()
开发者ID:huynq-tk-ios3,项目名称:iliat-erp-dump,代码行数:13,代码来源:dump_db_user.py


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