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


Python User.normalize方法代码示例

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


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

示例1: _do_login

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import normalize [as 别名]
    def _do_login(self, response):
        username = self.get_argument("username", None)
        password = self.get_argument("password", None)
        if not username or not password:
            # do something
            self.flash.error = "You must enter a username and password to proceed. Please try again."
            return 
        pw = hashlib.sha1(password).hexdigest()
        username = User.normalize(username)
        user = User.lookup(username)
        #check the password.
        if not user or user['password'] != pw:
            # do something
            self.flash.error = "Login not valid"
            return
        # check if user is suspended.
        if user.is_suspended() :
            self.flash.error = "Sorry the account you specified has been suspended."
            return    
        user.history.last_login = datetime.datetime.utcnow()
        Mongo.db.ui['users'].update({'_id': username}, {
                                                    '$set' : {'history.last_login': user.history.last_login},
                                                    '$inc' : {'history.num_logins' : 1}
                                                    })        
        #add to the session.
        self.session['username'] = user._id
        #check keep_logged_in
        if self.get_argument("keep_logged_in", False) == "on" :
            self.session['keep_logged_in'] = True
            
        self.set_current_user(user)
#        self.session['current_user']= user._id
        self.flash.notice = "Welcome, %s" % user._id
        self.write(username)
        self.finish("finished")
开发者ID:hc990,项目名称:let,代码行数:37,代码来源:account_control.py

示例2: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import normalize [as 别名]
    def post(self):
        username = self.get_argument("username", None)
        password = self.get_argument("password", None)
        if not username or not password:
            # do something
            self.flash.error = "You must enter a username and password to proceed. Please try again."
            self.session["flash"] = self.flash
            self.redirect("/login")
            return
        pw = hashlib.sha1(password).hexdigest()
        username = User.normalize(username)
        user = User.lookup(username)

        # check the password.
        if not user or user["password"] != pw:
            # do something
            self.flash.error = "Login not valid"
            self.redirect("/login")
            return

        # check if user is suspended.
        if user.is_suspended():
            self.flash.error = "Sorry the account you specified has been suspended."
            self.redirect("/")
            return

        user.history.last_login = datetime.datetime.utcnow()
        Mongo.db.ui["users"].update(
            {"_id": username},
            {"$set": {"history.last_login": user.history.last_login}, "$inc": {"history.num_logins": 1}},
        )
        # add to the session.
        self.session["username"] = user._id
        # check keep_logged_in
        #        print self.get_arguments("keep_logged_in", False)
        if self.get_argument("keep_logged_in", False) == "on":
            self.session["keep_logged_in"] = True

        self.set_current_user(user)
        self.flash.notice = "Welcome, %s" % user._id
        if user["roletype"] == 2:
            self.redirect("/manage")
        elif user["roletype"] == 3:
            self.redirect("/product")
        else:
            self.redirect("/signup")
开发者ID:ishida83,项目名称:let,代码行数:48,代码来源:account_control.py

示例3: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import normalize [as 别名]
 def post(self):
     username = self.get_argument("username", None)
     password = self.get_argument("password", None)     
     if not username or not password:   
         # do something
         self.flash.error = "You must enter a username and password to proceed. Please try again."
         self.session['flash'] = self.flash
         self.redirect("/login")
         return
     pw = hashlib.sha1(password).hexdigest()  
     username = User.normalize(username)
     user = User.lookup(username)
     
     #check the password.
     if not user or user['password'] != pw:
         # do something
         self.flash.error = "Login not valid"
         self.redirect("/login")
         return
     
     # check if user is suspended.
     if user.is_suspended() :
         self.flash.error = "Sorry the account you specified has been suspended."
         self.redirect("/")
         return
       
     user.history.last_login = datetime.datetime.utcnow()
     Mongo.db.ui['users'].update({'_id': username}, {
                                                 '$set' : {'history.last_login': user.history.last_login},
                                                 '$inc' : {'history.num_logins' : 1}
                                                 })        
     #add to the session.
     self.session['username'] = user._id
     self.session['keep_logged_in'] = True
     self.set_current_user(user)
     self.flash.notice = "Welcome, %s" % user._id
     forwardUrl = self.get_argument('next', '/')
     self.redirect("/syslog")  
开发者ID:hc990,项目名称:dss,代码行数:40,代码来源:account_control.py

示例4: trainUserModel

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import normalize [as 别名]
 def trainUserModel(self):
     user = User(REF_USER_ID, REF_USER_NAME)
     for td in self.trainingData:
         user.update_user(td)
     user.normalize()
     self.userData = user
开发者ID:rohitbegani,项目名称:FAIproject-CS5100,代码行数:8,代码来源:dataSet.py

示例5: trainUserModel

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import normalize [as 别名]
 def trainUserModel(self):
     user = User(REF_USER_ID, self.loc['lat'], self.loc['lon'])
     for td in self.trainingData:
         user.update_user(td)
     user.normalize()
     self.userData = user
开发者ID:ronnygeo,项目名称:YelpSocialEffects,代码行数:8,代码来源:dataSet.py


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