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


Python User.create方法代码示例

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


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

示例1: syncdb

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import create [as 别名]
def syncdb():
    from lib.util import find_subclasses
    from model import db, User, Distribution, Category, Page
    
    models = find_subclasses(db.Model)
    for model in models:
        if model.table_exists():
            model.drop_table()
        model.create_table()
        logging.info('created table:%s' % model._meta.db_table)
    
    Distribution.create(name = '免费配送', price = 0)
    Distribution.create(name = '上门自提', price = 0)
    Category.create(name = '积分商品', slug = 'credit', order = 1)
    Category.create(name = '搭配购买', slug = 'acc', order = 2)
    Category.create(name = '慕斯蛋糕', slug = 'mousse', order = 3)
    Category.create(name = '巧克力蛋糕', slug = 'chocolate', order = 4)
    Category.create(name = '乳酪蛋糕', slug = 'cheese', order = 5)
    Category.create(name = '乳脂奶油蛋糕', slug = 'creambutter', order = 6)
    Category.create(name = '冰淇淋蛋糕', slug = 'icecream', order = 7)
    Page.create(name = '吉米的厨房', slug = 'aboutus', content = '')
    Page.create(name = '包装展示', slug = 'bzzs', content = '')
    Page.create(name = '订购说明', slug = 'dgsm', content = '')
    Page.create(name = '如何收货', slug = 'rhsh', content = '')
    Page.create(name = '付款方式', slug = 'fkfs', content = '')
    Page.create(name = '配送范围', slug = 'psfw', content = '')
    User.create(mobile = 'root', password = User.create_password('111111'), group = 9)
    
    logging.info('superuser - username:root password:111111')
开发者ID:UniqueLJH,项目名称:yinongShop,代码行数:31,代码来源:manager.py

示例2: register

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import create [as 别名]
def register():
    '''
    Register a new user and generate then an API Key.
    Returns JSON-encoded username and API Key.
    '''
    reqjson = request.get_json()
    username = reqjson.get('username', '')
    password = reqjson.get('password', '')

    if not username or not password:
        logging.debug('Denying access for username of %s' % username)
        abort(400)

    try:
        user = User.create(username=username, password=password)
    except IntegrityError as e:
        logging.error('unable to register user with username %s' % username, e)
        abort(409)

    key = hashlib.sha1(username + password + str(datetime.now().microsecond) + SALT)

    apikey = ApiKey.create(owner=user.id, key=key.hexdigest())

    logging.warn('registered user with username %s' % username)
    return jsonify({'username': user.username, 'apikey': apikey.key}), 201
开发者ID:bostrt,项目名称:koala,代码行数:27,代码来源:koala.py

示例3: getUser

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import create [as 别名]
    def getUser(self, name):
        """Return a User object

        @type name: string, or User Object
        @param name: user name, or User object
        @rtype: User object"""
        return User.create(self.pm_getUserManager().getUser(self._unbox(name)),self._modelDataManager)
开发者ID:racktivity,项目名称:ext-pylabs-core,代码行数:9,代码来源:ConfluenceImpl.py

示例4: adminCreation

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import create [as 别名]
def adminCreation():
    form = forms.UserCreationForm()
    if form.validate_on_submit():
        user = User.create(form.username.data, form.password.data)
        User(user.id).makeAdmin()
        return user.serialize()
    else:
        raise MissingFieldsError(form.errors.keys())
开发者ID:hugoatease,项目名称:encas,代码行数:10,代码来源:encas.py

示例5: addUser

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import create [as 别名]
    def addUser(self, name, fullName, password, email = None, url = None):
        """Create a User

        @param name: user's name
        @param fullName: user's full name
        @param password: user's password
        @param email: user's email (default value is set by Confluence)
        @param url: user's URL on Confluence (default value is set by Confluence)
        @rtype: User object
        @return: newly created User"""
        return User.create(self.pm_getUserManager().addUser(name, fullName, password, email, url),self._modelDataManager)
开发者ID:racktivity,项目名称:ext-pylabs-core,代码行数:13,代码来源:ConfluenceImpl.py

示例6: sign_up

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import create [as 别名]
def sign_up():
	if 'name' in bottle.request.POST and 'password' in bottle.request.POST:
		name= bottle.request.POST['name']
		if name not in reserved_usernames.split():
			password = bottle.request.POST['password']
			user = User.create(name,password)
			if user:
				sess = Session(bottle.request,bottle.response)
				sess['id'] = user.id
				sess.save()
				bottle.redirect('/home')
	return bottle.template('login',page='login',error_login=False,error_signup=True,logged=False)
开发者ID:fisheuler,项目名称:retwitter,代码行数:14,代码来源:app.py

示例7: index

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import create [as 别名]
def index():
    if request.method == "POST":
        form = FormValidation(dict(request.form))

        if form.flash_messages:
            for message, category in form.flash_messages:
                flash(message, category)
            return render_template("index.html", old_form=request.form)
        else:
            salt = binascii.b2a_hex(os.urandom(15))
            hashed_pw = md5(request.form['password'] + salt).hexdigest()
            User.create(
                first_name=request.form['first_name'],
                last_name=request.form['last_name'],
                birthdate=request.form['birthdate'],
                email=request.form["email"],
                password=hashed_pw,
                salt=salt,
            )
            flash("Your user info was successfully submitted", "success")
            return redirect("/login")

    return render_template('index.html', old_form=None)
开发者ID:LawerenceLee,项目名称:coding_dojo_projects,代码行数:25,代码来源:app.py

示例8: __init__

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import create [as 别名]
class Base:
  def __init__(self, database):
    self.model = User(database, bcrypt)

  def on_get(self, req, resp):
    if authorize_as(req.auth, 'developer'):
      resp.body = dumps(self.model.all())
    else:
      raise HTTPUnauthorized('unautharized', 'unautharized')

  def on_post(self, req, resp):
    body = authorize_body(req)
    new_user = self.model.create(body)
    resp.status = HTTP_201
    resp.body = dumps(new_user)
开发者ID:monster-club,项目名称:trainer-card,代码行数:17,代码来源:Base.py

示例9: listUsers

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import create [as 别名]
    def listUsers(self):
        """Return a list of current users

        @rtype: User List
        @return: list of available Users"""
        return tuple(User.create({'name':name},self._modelDataManager) for name in self.pm_getUserManager().listUsers())
开发者ID:racktivity,项目名称:ext-pylabs-core,代码行数:8,代码来源:ConfluenceImpl.py

示例10: raw_input

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import create [as 别名]
from getpass import getpass
from model import User
from encas import app

print "Administrator account creation"
username = raw_input("Username: ")

while True:
	password = getpass("Password: ")
	confirm = getpass("Password confirmation: ")
	if password == confirm:
		break

with app.app_context():
	new = User.create(username, password)
	User(new.id).makeAdmin()
开发者ID:hugoatease,项目名称:encas,代码行数:18,代码来源:setup.py


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