本文整理汇总了Python中model.User.username方法的典型用法代码示例。如果您正苦于以下问题:Python User.username方法的具体用法?Python User.username怎么用?Python User.username使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.username方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import username [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)
示例2: regiest
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import username [as 别名]
def regiest():
user = User()
user.username = request.form['username']
user.password=utils.getenctry(request.form['password'])
user.email = request.form['email']
user.adduser()
session['username'] = user.username
flash("Welcome, %s!" % session['username'])
return redirect(url_for('home'))
#return (jsonify(user=user.to_json()))
示例3: adduser
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import username [as 别名]
def adduser():
user=User()
requeststr = request.query_string
params=utils.getparam(unquote(requeststr))
user.username=params['username']
user.email=params['email']
user.password=params['password']
user.sex=params['sex']
user.adduser()
return jsonify(msg='0000')
示例4: login_google_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import username [as 别名]
def login_google_user(self):
"""
associate the sesion object with google user object.
"""
session = self.session
google_user = users.get_current_user()
if google_user and (session.user is None):
users_ = User.all().filter("email", google_user.email())
if users_.count() == 0:
user = User()
user.email = google_user.email()
user.username = google_user.nickname()
user.put()
else:
user = users_[0]
self.login_user(user)
示例5: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import username [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.')