本文整理汇总了Python中model.user.User.get_or_insert方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_or_insert方法的具体用法?Python User.get_or_insert怎么用?Python User.get_or_insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.user.User
的用法示例。
在下文中一共展示了User.get_or_insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_or_insert [as 别名]
def get(self):
path = 'member/expose_social_data.html'
user = users.get_current_user()
User.get_or_insert(key_name=user.email())
template_values = {'name':user.nickname(),
'github_auth_url': get_github_auth_url(),
'dribbble_auth_url': get_dribbble_auth_url(),
'linkedin_auth_url': get_linkedin_auth_url()}
self.write(self.get_rendered_html(path, template_values), 200)
示例2: get
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_or_insert [as 别名]
def get(self):
code = self.request.get('code')
email = self.request.get('state')
response = urlfetch.fetch(get_fb_token_url(email, code))
access_token = response.content.split('&')[0].split('=')[1]
user_profile = json.loads(urlfetch.fetch('https://graph.facebook.com/me?access_token=' + access_token).content)
user_object = User.get_or_insert(user_profile['email'], id=user_profile['id'], name=user_profile['name'], access_token=access_token)
vals = {
'email':email
}
intermediate_path = os.path.join(os.path.dirname(__file__), '../../templates/momentary_message.html')
self.response.out.write(template.render(intermediate_path, vals))
示例3: register
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_or_insert [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)