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


Python User.gender方法代码示例

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


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

示例1: post

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import gender [as 别名]
 def post(self, error_msg=None):
     email = self.request.get("email")
     username = self.request.get("username")
     users = User.all().filter('email', email)
     user = User()
     user.email = email
     user.username = username
     user.fullname = self.request.get("firstname")+" "+self.request.get("lastname")
     user.birthday = datetime.datetime.strptime(self.request.get("birthday"), '%Y-%m-%d')
     user.set_password(self.request.get("password")) #set password. need encrypt. 
     user.firstname = self.request.get("firstname")
     user.lastname = self.request.get("lastname")
     user.country = self.request.get("country")
     gender = self.request.get("gender")
     if gender:
         gender_ = str(gender)[0:1]
         user.gender = gender_
     if users.count() == 0:
         user.put()
         #init() the session
         sessions.Session().login_user(user)
         self.redirect("/")
         return
     else:
         error_msg = "That email address has already been registered."
     template_values = {
        "temp_user": user,
        "error": error_msg
     }
     self.generate('signup.html',template_values)
开发者ID:Git-Host,项目名称:cpedialog,代码行数:32,代码来源:login.py

示例2: load_users

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import gender [as 别名]
def load_users(session):
    with open('seed_data/u.user', 'rb') as csvfile:
        userreader = csv.reader(csvfile, delimiter = '|')
        for userrow in userreader:
            u = User() 
            u.id = userrow[0]
            u.age = userrow[1]
            u.gender = userrow[2]
            u.occupation = userrow[3]
            u.zipcode = userrow[4]
            u.email = None
            u.password = None

            session.add(u)
开发者ID:k8k,项目名称:HBRatings,代码行数:16,代码来源:seed.py

示例3: get

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import gender [as 别名]
    def get(self):
        args = self.args_to_dict()
    
        s = {}
        self.session = sessions.Session()
        if self.session['openid_stuff']:
            try:
                s = pickle.loads(str(self.session['openid_stuff']))
            except:
                pass
    
        consumer = Consumer(s, store.DatastoreStore())
        if not consumer:
            return
        fetchers.setDefaultFetcher(fetcher.UrlfetchFetcher())
        auth_response = consumer.complete(args, self.request.uri)
        if auth_response.status == 'success':
            openid = auth_response.getDisplayIdentifier()

            #when user add openid from profile setting, just return status.
            if self.session['openid_userid']:
                user = User.get(self.session['openid_userid'])
                if user:
                    users = User.all().filter('openids', openid)
                    if users.count() == 0:
                        user.openids += [db.Category(openid.strip().encode('utf8'))]
                        user.put()
                    else:
                        msg = "OpenID had already been attached to another user."
                        if users.count()==1 and users.get() == user:
                            msg = "OpenID had already been attached to you."
                        self.generate('user/user_profile_openid_verify.html',
                                      {"status":"fail","msg":msg})
                        return
                self.generate('user/user_profile_openid_verify.html',
                              {"status":"success","msg":"Attach OpenID to user successfully."})
                return

            sreg_data = sreg.SRegResponse.fromSuccessResponse(auth_response)
            users = User.all().filter('openids', openid)
            if users.count() == 0:
                user = User()
                user.openids = [db.Category(openid.strip().encode('utf8'))]
                if sreg_data:
                    user.username = sreg_data["nickname"]
                    user.fullname = sreg_data["fullname"]
                    user.country = sreg_data["country"]
                    user.birthday = datetime.datetime.strptime(sreg_data["dob"], '%Y-%m-%d')
                    user.gender = sreg_data["gender"]
                    user.language = sreg_data["language"]
                    user.postcode = sreg_data["postcode"]
                    #user.email = sreg_data["email"]
                else:
                    user.username = openid
                user.put()
                self.session.login_user(user)
                self.redirect('/user')
                return
            else:
                user = users[0]

            self.session.login_user(user)
            self.redirect('/')
            return
        else:
            #when user add openid from profile setting, just return status.
            if self.session['openid_userid']:
                self.generate('user/user_profile_openid_verify.html',
                              {"status":"fail","msg":"Attach OpenID to user unsuccessfully: OpenID verification failed."})
                return
            self.show_main_page('OpenID verification failed.')
开发者ID:Git-Host,项目名称:cpedialog,代码行数:73,代码来源:login.py

示例4: license

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import gender [as 别名]
def license():
    switch_led(4)
    
    # Check if first letter is % or ;
    # If CA format: lines[0][1:3] = CA
    
    # GET USER ID
    # print("Pretesting for manual")
    # DECODE LICENSE
    data = request.form['license_data']
    
    # print data
    # print data[1:3] == "CA"
    # 
    # print("Testing for manual")
    
    # RECORD data TO MYSQL ANYWAY?

    if data[1:3] == "CA":
        user = User(data)
        
        lines = data.split('\n')
        line_one = lines[0].split('^')

        # # ADDRESS
        user.street = line_one[2].title()
        user.state = lines[0][1:3]
        user.city = line_one[0][3:].title()
        user.zipcode = lines[2][3:8]
        
        #googleImage(user.city)
        
        # NAME
        name = line_one[1].split('$')
        user.forename = name[1].capitalize()
        user.surname = name[0].capitalize()
        if len(name) > 2:
            user.middle_name = name[2].capitalize()
    
        # OTHER DETAILS
        month = int(lines[1][25:27])
        if month > 12: month = 9
        # user.dob = datetime.strptime(lines[1][21:29],"%Y%m%d")
        user.dob = "%s-%02d-%s" % (lines[1][21:25], month, lines[1][27:29])
        if lines[2][30:31] == 'M':
            user.gender = 'Male'
        else: user.gender = 'Female'
        user.height = int(lines[2][31])*12 + int(lines[2][32:34])
        user.weight = lines[2][34:37]
        user.hair = lines[2][37:40]
        user.eyes = lines[2][40:43]
        user.drivers_license = lines[1][9:16]
        
        db.session.add(user)
        db.session.commit()
        
        return render_template('license.html', user=user)
    else:
        switch_led(3)
        # TODO: Fall back if not read correctly?
        
        return render_template('manual.html')
开发者ID:johndryan,项目名称:prizm,代码行数:64,代码来源:multiplex.py


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