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


Python User.by_name方法代码示例

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


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

示例1: get_username

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import by_name [as 别名]
 def get_username(self):
     _username = self.get_argument('name', '')
     if User.by_name(_username) is not None:
         raise ValidationError("Username already exists")
     elif len(_username) < 3:
         raise ValidationError("Username is too short, must be 3+ chars")
     return _username
开发者ID:fun-alex-alex2006hw,项目名称:Sonar-Server,代码行数:9,代码来源:AdminHandlers.py

示例2: start_battle

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import by_name [as 别名]
 def start_battle(self, session):
     """ Creates a battle instance and links it to an sid """
     user = User.by_name(session.data["name"])
     self.lock.acquire()
     self.battles[session.id] = Battle(user)
     self.lock.release()
     return self.battles[session.id]
开发者ID:hathcox,项目名称:Arthur,代码行数:9,代码来源:Battle.py

示例3: post

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import by_name [as 别名]
    def post(self):
        have_error = False
        self.username = self.request.get("username")
        self.password = self.request.get("password")
        self.verify = self.request.get("verify")
        self.email = self.request.get("email")

        params = dict(username = self.username, email = self.email)

        if not valid_username(self.username):
            params['error_username'] = "Invalid username"
            have_error = True

        u = User.by_name(self.username)
        if u:
            params['error_username'] = "That user already exists"
            have_error = True

        if not valid_password(self.password):
            params['error_password'] = "Invalid password"
            have_error = True
        elif self.password != self.verify:
            params['error_verify'] = "Your password didn't match"
            have_error = True

        if not valid_email(self.email):
            params['error_email'] = "Invalid email"
            have_error = True

        if have_error:
            self.render('ioffer_signup_form.html', params = params)
        else:
            self.done()
开发者ID:japavi,项目名称:ioffer,代码行数:35,代码来源:main.py

示例4: wrapper

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import by_name [as 别名]
 def wrapper(self, *args, **kwargs):
     if self.session is not None:
         user = User.by_name(self.session['username'])
         if user is not None and user.has_permission(permission):
             return method(self, *args, **kwargs)
     logging.warn("Attempted unauthorized access from %s to %s" % (
         self.request.remote_ip, self.request.uri,
     ))
     self.redirect(self.application.settings['forbidden_url'])
开发者ID:DJHartley,项目名称:Veil,代码行数:11,代码来源:SecurityDecorators.py

示例5: render

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import by_name [as 别名]
 def render(self, *args, **kwargs):
     session_manager = SessionManager.Instance()
     session = session_manager.get_session(
         self.handler.get_secure_cookie('auth'), self.request.remote_ip)
     if session != None:
         if session.data['menu'] == 'user':
             user = User.by_name(session.data['name'])
             if user != None:
                 return self.render_string('menu/user.html', experience=user.experience, gold=user.gold, name=user.name, level=user.level)
         elif session.data['menu'] == 'admin':
             return self.render_string('menu/admin.html', uri=self.handler.request.uri)
     return self.render_string('menu/public.html', uri=self.handler.request.uri)
开发者ID:hathcox,项目名称:Arthur,代码行数:14,代码来源:Menu.py

示例6: post

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import by_name [as 别名]
 def post(self, *args, **kwargs):
     user = User.by_name(self.get_argument('username', ''))
     password = self.get_argument('password', '')
     if user is not None:
         if user.validate_password(password):
             self.login_success(user)
             self.redirect('/user')
         else:
             self.login_failure()
     else:
         # Prevent user enumeration via timing attack
         User._hash_password(password)
         self.login_failure()
开发者ID:0x68,项目名称:TornadoAppTemplate,代码行数:15,代码来源:PublicHandlers.py

示例7: done

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import by_name [as 别名]
    def done(self):
        #make sure the user doesn't already exist
        u = User.by_name(self.username)
        if u:
            msg = 'That user already exists.'
            self.render('signup.html', error_username = msg)
        else:
            u = User.register(self.username, self.password, self.email)
            u.put()

            self.login(u)
            self.redirect("/wiki/")
            self.render("welcome.html", username = self.username)
开发者ID:joapaspe,项目名称:udacity-web,代码行数:15,代码来源:Signup.py

示例8: post

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import by_name [as 别名]
 def post(self):
     """ Login and create a new session """
     user = User.by_name(self.get_argument('username', ''))
     if user is not None:
         session = self.login_attempt(user)
         self.write(session)
     else:
         # To prevent a timing attack to enumerate users, since hashing
         # takes non-zero time, we only we normally only hash if we got a
         # user from the db, we just hash whatever we got anyways before
         # telling the client the auth failed.
         bcrypt.hashpw("password", bcrypt.gensalt())
         self.login_failure()
开发者ID:moloch--,项目名称:TornadoAppTemplate,代码行数:15,代码来源:AuthenticationHandlers.py

示例9: loged_user

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import by_name [as 别名]
def loged_user(logged_username, update = False):
    key = 'loged_user' + str(logged_username)
    user = memcache.get(key)
    if user is None or update:
        logging.error('DB QUERY user')
        memcache.delete(key)

        user = User.by_name(str(logged_username))
        memcache.set(key, user)
        #logging.error('memcache 1 [%s]:%s' % (key,memcache.get(key).name))
        logging.error('memcache.get(key).profiles.count:%s' % memcache.get(key).profiles.count())
        if memcache.get(key).profiles.count() > 0:
            logging.info('memcache 2 [%s]:%s' % (key,memcache.get(key).profiles[0].name)) #no quitar esta traza si no no refresca los perfiles al modificar el perfil
    return user
开发者ID:japavi,项目名称:ioffer,代码行数:16,代码来源:main.py

示例10: post

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import by_name [as 别名]
 def post(self):
     ''' Login and create a new session '''
     user = User.by_name(self.get_argument('username', ''))
     password = str(self.get_argument('password', ''))
     if user is not None:
         # Each of these methods writes it own response
         if user.validate_password(password):
             self.login_success(user)
         else:
             self.login_failure()
     else:
         # To prevent a timing attack to enumerate users, since hashing
         # takes non-zero time, we only we normally only hash if we got a
         # user from the db, we just hash whatever we got anyways before
         # telling the client the auth failed.
         bcrypt.hashpw(password, bcrypt.gensalt())
         self.login_failure()
开发者ID:fun-alex-alex2006hw,项目名称:Sonar-Server,代码行数:19,代码来源:PublicHandlers.py

示例11: post

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import by_name [as 别名]
    def post(self):
        have_error = False
        username = self.request.get('username')
        password = self.request.get('password')
        verify = self.request.get('verify')
        email = self.request.get('email')

        params = dict(username = username,
                      email = email)

        if not valid_username(username):
            params['error_username'] = "That's not a valid username."
            have_error = True

        if not valid_password(password):
            params['error_password'] = "That wasn't a valid password."
            have_error = True
        elif password != verify:
            params['error_verify'] = "Your passwords didn't match."
            have_error = True

        if not valid_email(email):
            params['error_email'] = "That's not a valid email."
            have_error = True

        if have_error:
            self.render('signup-form.html', **params)
        else:
            #make sure the user doesn't already exist
            u = User.by_name(username)
            if u:
                msg = 'That user already exists.'
                self.render('signup-form.html', error_username = msg)
            else:
                u = User.register(username, password, email)
                u.put()

                self.login(u)
                self.redirect('/blog/welcome')
开发者ID:feynmanliang,项目名称:AppEngine-Blog,代码行数:41,代码来源:Auth.py

示例12: post

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import by_name [as 别名]
    def post(self):
        username = self.request.get("username")
        password = self.request.get("password")
        verify = self.request.get("verify")
        email = self.request.get("email")

        valid = True
        error = {}

        v_username = validations.valid_username(username)
        v_password = validations.valid_password(password)
        v_email = validations.valid_email(email)
        if not v_username or v_username.string != username:
            valid = False
            error["user_error"] = "That's not a valid username."
        if not v_password or v_password.string != password:
            valid = False
            error["valid_pass_error"] = "That's not a valid password."
        if verify != password:
            valid = False
            error["pass_match_error"] = "Your passwords didn't match."
        if len(email) > 0 and (not v_email or v_email.string != email):
            valid = False
            error["email_error"] = "That's not a valid email."

        if not valid:
            self.render("signup.html", email=email, username=username, error=error)
        else:
            user = User.by_name(username)
            if user:
                self.render("signup.html", error={"user_error": "User already exists."})
            else:
                user = User.register(username, password)
                user.put()
                self.login(user)
                self.redirect("/welcome")
开发者ID:jhu104,项目名称:Web_dev,代码行数:38,代码来源:SignupHandler.py


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