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


Python User.new方法代码示例

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


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

示例1: save

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import new [as 别名]
 def save(self):
     id = int(self.get_argument('id',0))
     name = self.get_argument('name')
     passwd = self.get_argument('password','')
     is_root = int(self.get_argument('is_root',0))
     is_staff = int(self.get_argument('is_staff',0))
     orgid = int(self.get_argument('orgid',0))
     email = self.get_argument('email','')
     phone = self.get_argument('phone','')
     args = self.request.arguments
     role_ids = [self.get_argument(i,'') for i in self.request.arguments if i.startswith('role__')]
     role_ids = [int(i) for i in role_ids if i]
     print role_ids
     if id:
         u = User.mgr(ismaster=True).Q().filter(id=id)[0]
     else:
         u = User.new()
     u.name,u.passwd,u.is_root,u.is_staff,u.orgid = name,passwd,is_root,is_staff,orgid
     u.email,u.phone = email,phone
     u = u.save()
     id = u.id
     cur_roles = [i.role_id for i in UserRole.mgr().Q().filter(uid=id)]
     new_roles = [int(i) for i in role_ids]
     for i in [i for i in cur_roles if i not in new_roles]:
         ur = UserRole.mgr(ismaster=1).Q().filter(uid=id,role_id=i)[0]
         ur and ur.delete()
     for i in [i for i in new_roles if i not in cur_roles]:
         ur = UserRole.new()
         ur.uid,ur.role_id = id,i
         ur.save()
     self.json2dwz('200','closeCurrent','ulist',forwardUrl='user/list')
开发者ID:appleface2050,项目名称:yuezhang_logstat,代码行数:33,代码来源:user.py

示例2: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import new [as 别名]
 def post(self):
     name = self.get_argument('name', '')
     email = self.get_argument('email', '')
     password = self.get_argument('password', '')
     if not name or len(name) > 15:
         self.render('join.html', error=111, name=name, email=email)
         return
     match = re.search(r'[\w.-][email protected][\w.-]+', email)
     if not match:
         self.render('join.html', error=112, name=name, email=email)
         return
     if not password:
         self.render('join.html', error=110, name=name, email=email)
         return
     user = User.get_by_email(email)
     if user:
         self.render('join.html', error=113, name=name, email=email)
         return
     user = User.new(name, email)
     if user:
         user.update_password(encrypt(password))
     else:
         self.render('join.html', error=114)
     self.set_secure_cookie('user', user.id, expires_days=30)
     self.redirect(self.get_argument('next', '/'))
开发者ID:Daniel7725,项目名称:diggit,代码行数:27,代码来源:login.py

示例3: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import new [as 别名]
    def post(self):
        username = self.get_argument("username")
        password = self.get_argument("password")
        password_again = self.get_argument("password_again")
        next = self.get_argument('next', None)

        error = False
        if not (3 <= len(username) <= 15):
            error = True
            self.messages.error("用户名长度必须在 3-15 之间")
        if len(password) < 3:
            error = True
            self.messages.error("密码长度必须大于等于3")
        if User.exist(username):
            error = True
            self.messages.error("用户已存在!")
        if password != password_again:
            error = True
            self.messages.error("两次输入的密码不一致!")

        if not error:
            u = User.new(username, password)
            self.messages.success("账户创建成功!")
            self.redirect(url_for('signin') + (('?next=%s' % next) if next else ''))
            return

        self.render('user/signup.html')
开发者ID:FashtimeDotCom,项目名称:fpage,代码行数:29,代码来源:user.py

示例4: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import new [as 别名]
    def post(self):
        username = self.get_argument('username', '')
        email = self.get_argument('email', '')
        password = self.get_argument('password', '')

        if not username or len(username) > 15:
            self.render('home/register.html', error=111, username=username, email=email)
            return
        match = re.search(r'[\w.-][email protected][\w.-]+', email)
        if not match:
            self.render('home/register.html', error=113, username=username, email=email)
            return
        if not password:
            self.render('home/register.html', error=110, username=username, email=email)
            return

        user = User.get_by_username(username)
        if user:
            self.render('home/register.html', error=112, username=username, email=email)
            return

        user = User.get_by_email(email)
        if user:
            self.render('home/register.html', error=114, username=username, email=email)
            return

        #走代理获取ip方式
        reg_ip = self.request.headers['X-Real-Ip']
        user = User.new(username, email, password, reg_ip)
        if user:
            self.set_secure_cookie('user_id', str(user.user_id), expires_days=30)
            self.redirect(self.get_argument('next', '/'))
        else:
            self.render('home/register.html', error=115)
开发者ID:ListFranz,项目名称:PyCMS-Tornado,代码行数:36,代码来源:login.py

示例5: add_or_get_user

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import new [as 别名]
def add_or_get_user(name):
    user = User.get_by_uid(name)
    if user:
        return user
    email = '[email protected]'
    city = 'Beijing'
    blog = 'http://fuyao.github.io'
    intro = 'I am a unittest!'
    return User.new(name, email, city, blog, intro, name)
开发者ID:Daniel7725,项目名称:diggit,代码行数:11,代码来源:__init__.py

示例6: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import new [as 别名]
 def post(self):
     username = self.get_argument('username', '')
     password = self.get_argument('pwd1', '')
     error = False
     if len(username) < 3:
         error = True
         self.messages.error('用户长度必须大于等于3!')
     if len(password) < 3:
         error = True
         self.messages.error('密码长度必须大于等于3!')
     if User.exist(username):
         error = True
         self.messages.error('用户已存在!')
     if not error:
         User.new(username, password)
         self.messages.success('账户创建成功!')
         self.redirect('/signin')
         return
     self.render('user/signup.html')
开发者ID:sbkkt,项目名称:words,代码行数:21,代码来源:user.py

示例7: first_run

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import new [as 别名]
def first_run():
    if User.count() == 0:
        u = User.new('root', '123')
        Board.new('初学者', u, '你们啊,还是需要学习一个。')
        Board.new('问与答', u, '但是你们问来问去的问题呀,都 too young, too simple.')
        Board.new('游戏开发', u, '游戏制作的种种')
        Board.new('WEB开发', u, '当下最热门的技术种类')
        Board.new('发起项目', u, '已有创意,就差一个程序员/设计师/策划/运营了!')
        Board.new('项目展示', u, '今天我作为一个长者,给你们分享一点人生的经验')
        Board.new('水区', u, '社区的哪一个牛人我没有见过?我跟他们谈笑风生!')
开发者ID:fy0,项目名称:Icarus,代码行数:12,代码来源:models.py

示例8: add_user

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import new [as 别名]
def add_user(request):
    name = 'unittest1'
    email = '[email protected]'
    city = 'Beijing'
    blog = 'http://daydayfree.github.io'
    intro = 'I am a unittest!'
    uid = 'unittest1'
    user = User.new(name, email, city, blog, intro, uid)
    self = request.instance
    self.user = user
    return user
开发者ID:Daniel7725,项目名称:diggit,代码行数:13,代码来源:test_user.py

示例9: add_user

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import new [as 别名]
def add_user(req):
    user_name = req.POST['username']
    u = User.new(user_name)
    u.password = req.POST['password']
    u.email = req.POST['email']
    u.is_active = req.POST['is_active']
    u.is_superuser = req.POST['is_superuser']
    u.group_id = req.POST['group_id']
    u.permission_list = req.POST['permission_list']
    instance = user.save_user(u)
    if instance:
       return json.json_response_ok('ok', 'add user success')
开发者ID:vincentchivas,项目名称:rampup,代码行数:14,代码来源:views.py

示例10: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import new [as 别名]
 def post(self):
     username = self.get_argument('username', '')
     password = self.get_argument('pwd1', '')
     password2 = self.get_argument('pwd2', '')
     verify_code = self.get_argument('verify_code', '').lower()
     next = self.get_argument('next', None)
     error = SIGNUP_KEY
     if len(username) < 3 or len(username) > 18:
         error = True
         self.messages.error('用户长度必须大于3小于18!')
     if password != password2:
         error = True
         self.messages.error('您输入的密码不一致!!')
     if len(password) < 3 or len(password) > 51:
         error = True
         self.messages.error('密码长度必须大于3小于50!')
     if User.exist(username):
         error = True
         self.messages.error('用户已存在!')
     if User.num_lim():
         error = True
         self.messages.error("注册用户过多,请联系管理员")
     '''
     if self.session['verify_code'] != verify_code:
         error = True
         self.messages.error('验证码不正确!')
         self.session['verify_code'] = ''
     '''
     if not error:
         User.new(username, password)
         u = User.auth(username, password)
         self.set_secure_cookie('u', u.key)
         self.messages.success('账户创建成功!')
         if next:
             return self.redirect(next)
         self.redirect('/')
     else:
         if next:
             return self.redirect(next)
         self.redirect('/')
开发者ID:jtwmyddsgx,项目名称:1024,代码行数:42,代码来源:user.py

示例11: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import new [as 别名]
    def post(self):
        username = self.get_argument("username")
        password = self.get_argument("pwd1")

        # 相比之前,目前这种方法更加实用
        error = False
        if len(username) < 3:
            error = True
            self.messages.error("用户长度必须大于等于3!")
        if len(password) < 3:
            error = True
            self.messages.error("密码长度必须大于等于3!")
        if User.exist(username):
            error = True
            self.messages.error("用户已存在!")

        if not error:
            User.new(username, password)
            self.messages.success("账户创建成功!")
            self.redirect("/login")
            return

        self.render("register.html")
开发者ID:sbkkt,项目名称:words,代码行数:25,代码来源:board.py

示例12: test_can_add_a_new_user

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import new [as 别名]
 def test_can_add_a_new_user(self):
     name = 'unittest1'
     email = '[email protected]'
     city = 'Beijing'
     blog = 'http://daydayfree.github.io'
     intro = 'I am a unittest!'
     uid = 'unittest1'
     new = User.new(name, email, city, blog, intro, uid)
     assert new
     assert new.name == name
     assert new.email == email
     assert new.city == city
     assert new.blog == blog
     assert new.intro == new.intro
     assert new.uid == uid
开发者ID:Daniel7725,项目名称:diggit,代码行数:17,代码来源:test_user.py

示例13: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import new [as 别名]
    def post(self):
        username = self.get_argument("username")
        password = self.get_argument("password")

        error = False
        if len(username) < 3:
            error = True
            self.messages.error("用户名长度必须大于等于3")
        if len(password) < 3:
            error = True
            self.messages.error("密码长度必须大于等于3")
        if User.exist(username):
            error = True
            self.messages.error("用户已存在!")

        if not error:
            u = User.new(username, password)
            self.messages.success("账户创建成功!")
            return self.redirect(url_for('signin'))

        self.render('user/signup.html')
开发者ID:Geoion,项目名称:fpage,代码行数:23,代码来源:user.py

示例14: import_user

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import new [as 别名]
def import_user():
    '''
    from a file split by \t import User
    深圳欣沣晟通讯_acc  145605
    '''
    fn = open("/home/zongkai/logstat_mysql/logstat/tools/import_user.txt")
    for i in fn.readlines():
        line = i.strip().split('\t')
        name = line[0]
        passwd = line[1]
        try: 
            u = User.new()
            u.name = name
            u.passwd = passwd
            u.is_root = 0
            u.is_staff = 0
            u.orgid = 18
            u.email = name+"@163.com"
        
            #print u
            #u.save()
        except:
            print u
开发者ID:appleface2050,项目名称:yuezhang_logstat,代码行数:25,代码来源:merge_perm_attr_sql.py


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