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


Python User.getUser方法代码示例

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


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

示例1: validate

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import getUser [as 别名]
    def validate(self):
        dbuser=User.getUser(self.user)
        if (dbuser==None):
            self.handler.redirect('/register')
            return

        if (dbuser.verified==True):
            self.handler.redirect('/list')
            return

        if (dbuser.regcode==None or dbuser.regcode==''):
            self.handler.redirect('/register')
            return
        
        values={}
        code=self.request.get('code')
        if (code!='' and dbuser.regcode==code):
            dbuser.verified=True
            dbuser.regcode=''
            dbuser.put()
            self.handler.redirect('/list')
            return
        values['user']=self.user
        values['email']=self.user.email()
        values['captcha']=Captcha.getCaptchaHtml()
        if (code!=''):
            values['reason']='Sorry, the entered code \"'+code+'\" does not match our records. Please try again.'
        return self.render('validate',values)
开发者ID:scotte,项目名称:sailtrack,代码行数:30,代码来源:protected.py

示例2: register

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import getUser [as 别名]
 def register(self):
     dbuser=User.getUser(self.user)
     if (dbuser!=None and dbuser.verified!=None and dbuser.verified==True):
         self.handler.redirect('/list')
         return
     
     go=self.request.get('go')
     if (dbuser!=None and go!="true"):
         self.handler.redirect("/validate")
         return
     
     values={}
     values['user']=self.user
     values['email']=self.user.email()
     values['captcha']=Captcha.getCaptchaHtml()
     if (go=="true"):
         challenge = self.request.get('recaptcha_challenge_field')
         response  = self.request.get('recaptcha_response_field')
         captcha = Captcha.validateCaptcha(challenge, response)
         if (not captcha.is_valid):
             self.handler.redirect("/register")
             logging.warn('Captcha result was false')
             return
         logging.warn('Captcha result was true')
         sha1=hashlib.sha1()
         sha1.update(str(random.randint(0,sys.maxint)))
         sha1.update(str(time.time()))
         sha1.update(self.user.email())
         codehash=sha1.hexdigest()
         logging.info(codehash)
         #TODO: Send reg email here
         dbuser=User.get_or_insert(key_name=self.user.user_id())
         dbuser.regcode=codehash
         dbuser.put()
         self.handler.redirect("/validate")
         return
     return self.render('register',values)
开发者ID:scotte,项目名称:sailtrack,代码行数:39,代码来源:protected.py

示例3: dispatch

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import getUser [as 别名]
    def dispatch(self):
        method=Controller.methodre.match(self.request.path)
        if (method == None):
            context='root' # Since we can't have a method called '/' :-)
        else:
            context=method.group(1)

        cached=memcache.get(self.request.url)
        view=None

        if (cached==None):
            # First try to find a view from Public
            view=Public(self)
            function=getattr(view,context,None)
            allowcaching=True
    
            # Second try to find a view from Protected
            if (function==None):
                allowcaching=False
                check=getattr(Protected(self,None),context,None)
                if (check!=None):
                    user = users.get_current_user()
                    if (user!=None):
                        view=Protected(self,user)
                        function=getattr(view,context,None)
                    else:
                        # Method is there, but we aren't logged in, redirect to login
                        self.redirect(users.create_login_url(self.request.uri))
                        return
    
            # Third try to find a view from Private
            if (function==None):
                allowcaching=False
                check=getattr(Private(self,None,None),context,None)
                if (check!=None):
                    user = users.get_current_user()
                    if (user==None):
                        self.redirect(users.create_login_url(self.request.uri))
                        return
    
                    dbuser=User.getUser(user)
                    if (dbuser!=None and dbuser.verified==True):
                        view=Private(self,user,dbuser)
                        function=getattr(view,context,None)
                    else :
                        if (dbuser==None or dbuser.regcode==None or dbuser.regcode==''):
                            logging.info('User does not exist')
                            self.redirect("/register")
                            return
                        else:
                            logging.info('Unverified user')
                            self.redirect("/validate")
                            return
    
            if (function==None):
                self.redirect("/")
                return

            logging.info('Dispatching to view '+context)
            cached=function()
            content=view.getContentType()
            if (allowcaching and cached!=None):
                memcache.add(self.request.url,cached,120)
                memcache.add("type."+self.request.url,content,120)
        else:
            logging.info('Using cached render for '+self.request.url)
            content=memcache.get("type."+self.request.url)

        self.response.headers['Content-Type'] = content
        self.response.out.write(cached)
        logging.info(users.create_logout_url(self.request.uri))

        return
开发者ID:scotte,项目名称:sailtrack,代码行数:75,代码来源:controller.py


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