本文整理汇总了Python中models.UserInfo.put方法的典型用法代码示例。如果您正苦于以下问题:Python UserInfo.put方法的具体用法?Python UserInfo.put怎么用?Python UserInfo.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.UserInfo
的用法示例。
在下文中一共展示了UserInfo.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_new_user
# 需要导入模块: from models import UserInfo [as 别名]
# 或者: from models.UserInfo import put [as 别名]
def register_new_user(email, password):
user = UserInfo(
email=email,
password=password,
id=email
)
user.put()
示例2: post
# 需要导入模块: from models import UserInfo [as 别名]
# 或者: from models.UserInfo import put [as 别名]
def post(self):
userinfo = self.currentuser
if userinfo == None:
userinfo = UserInfo()
userinfo.nickname = cgi.escape(self.request.get('nickname'))
if is_empty(userinfo.nickname):
self.render_edit("nickname can't be empty")
return
email = cgi.escape(self.request.get('email'))
avatar = self.request.get('avatar')
first_login = self.request.get('first_login')
if avatar != '':
avatar = images.resize(avatar, 128)
userinfo.avatar = db.Blob(avatar)
if email == '':
email = 'none'
userinfo.email = email
if first_login != '':
userinfo.lastposted = date.today()
userinfo.lastvoted = userinfo.lastposted
userinfo.put()
self.redirect('/')
示例3: get
# 需要导入模块: from models import UserInfo [as 别名]
# 或者: from models.UserInfo import put [as 别名]
def get(self, mode = ''):
if mode == 'login':
if 'allowed' in self.request.cookies and \
self.request.cookies['allowed'].count('_'):
_twitter_id, _login_hash = \
self.request.cookies['allowed'].split('_', 1)
user_info = UserInfo.all().filter('twitter_id =', _twitter_id).get()
if user_info and _sha512(user_info.acc_key) == _login_hash:
self.session = Session()
self.session['twitter_id'] = _twitter_id
return self.redirect('/home')
auth = _oauth_handler()
auth_url = auth.get_authorization_url()
memcache.set(auth.request_token.key,
auth.request_token.secret,
3600)
return self.redirect(auth_url)
elif mode == 'verify':
auth = _oauth_handler()
ver = self.request.get('oauth_verifier')
req_key = self.request.get('oauth_token')
req_sec = memcache.get(req_key)
auth.set_request_token(req_key, req_sec)
acc_token = auth.get_access_token(ver)
api = tweepy.API(auth_handler = auth)
me = api.me()
if not UserInfo.all().filter('twitter_id =', str(me.id)).get():
user_info = UserInfo(twitter_id = str(me.id),
screen_name = me.screen_name,
name = me.name,
image = me.profile_image_url,
acc_key = acc_token.key,
acc_sec = acc_token.secret)
user_info.put()
self.session = Session()
self.session.delete_item('twitter_id')
self.session['twitter_id'] = str(me.id)
c = SimpleCookie()
c['allowed'] = '%d_%s' % (me.id, _sha512(acc_token.key))
c['allowed']['path'] = '/auth'
c['allowed']['expires'] = 86400 * 10
self.response.headers.add_header('Set-Cookie', c.output(header = ''))
return self.redirect('/home')
elif mode == 'logout':
user_info = _login_user(self)
if user_info:
self.session = Session()
self.session.delete_item('twitter_id')
return self.redirect('/')
示例4: create_user
# 需要导入模块: from models import UserInfo [as 别名]
# 或者: from models.UserInfo import put [as 别名]
def create_user(self, name, pwd):
hsh = self.make_hash(name, pwd)
new_user = UserInfo(name=name, hash_str=hsh)
new_user.put()
return new_user