本文整理汇总了Python中model.User.id方法的典型用法代码示例。如果您正苦于以下问题:Python User.id方法的具体用法?Python User.id怎么用?Python User.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import id [as 别名]
def post(self):
self.nickname = self.request.get('nickname')
self.email = self.request.get('email')
self.password = self.request.get('password')
self.confirmPassword = self.request.get('confirmPassword')
self.username = self.request.get('username')
salt = str(uuid.uuid4()).replace('-','')
passwordHash = hashlib.sha1(self.password + salt).hexdigest()
key = User(
nickname = self.nickname,
email = self.email,
password = str(passwordHash),
salt = salt,
username = self.username
).put()
uid = key.id()
sid = str(uuid.uuid4()).replace('-','')
memcache.set(sid, uid, 36000)
self.response.headers.add_header('Set-Cookie',
'sid=%s; path=/' % sid)
if xhr(self):
resp = {
'username': self.username,
'uid': uid
}
return self.response.out.write(json.dumps(resp))
else:
self.redirect('/')
示例2: oauth_authorized
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import id [as 别名]
def oauth_authorized(resp):
"""Called after authorization. After this function finished handling,
the OAuth information is removed from the session again. When this
happened, the tokengetter from above is used to retrieve the oauth
token and secret.
Because the remote application could have re-authorized the application
it is necessary to update the values in the database.
If the application redirected back after denying, the response passed
to the function will be `None`. Otherwise a dictionary with the values
the application submitted. Note that Twitter itself does not really
redirect back unless the user clicks on the application name.
"""
next_url = request.args.get('next') or url_for('index')
if resp is None:
#TODO: show friendly message
#flash(u'You denied the request to sign in.')
return redirect(next_url)
screen_name = resp['screen_name']
oauth_token = resp['oauth_token']
oauth_token_secret = resp['oauth_token_secret']
user = User.select_by_screen_name(screen_name)
if not user:
app.logger.debug('User not found on database. Using the Twitter API')
auth = tweepy.OAuthHandler(config.CONSUMER_KEY, config.CONSUMER_SECRET)
auth.set_access_token(oauth_token, oauth_token_secret)
api = tweepy.API(auth)
twitter_user = api.get_user(screen_name=screen_name)
user = User()
user.id = twitter_user.id
user.screen_name = twitter_user.screen_name
user.blocked = 'N'
user.name = twitter_user.name
user.description = twitter_user.description
user.created_at = twitter_user.created_at
user.friends_count = twitter_user.friends_count
user.followers_count = twitter_user.followers_count
user.statuses_count = twitter_user.statuses_count
user.profile_image_url = twitter_user.profile_image_url
user.lang = twitter_user.lang
user.location = twitter_user.location
user.oauth_token = oauth_token
user.oauth_token_secret = oauth_token_secret
User.add(user)
else:
user.oauth_token = oauth_token
user.oauth_token_secret = oauth_token_secret
flask.session['screen_name'] = resp['screen_name']
flask.session['oauth_token'] = resp['oauth_token']
flask.session['oauth_token_secret'] = resp['oauth_token_secret']
commit()
return flask.redirect(next_url)
示例3: load_users
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import id [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)
示例4: climbers
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import id [as 别名]
def climbers(self, summit_id):
climbers = []
sql = """SELECT
year,
month,
day,
comment,
users.id,
users.name,
users.preview
FROM users LEFT JOIN climbs ON climbs.user_id=users.id
LEFT JOIN summits ON climbs.summit_id=summits.id
WHERE climbs.summit_id=%s ORDER BY year, month, day;"""
with self.get_cursor() as cur:
cur.execute(sql, (summit_id, ))
for row in cur:
u = User()
u.id = row['id']
u.name = row['name']
u.preview = row['preview']
climbers.append(
{'user': u, 'date': InexactDate.fromdict(row),
'comment': row['comment']})
return climbers
示例5: create_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import id [as 别名]
def create_user(self, username, rolename=None):
u = User(username=username, assigned_rolename=rolename)
u.id = self.calculate_id(username)
u.type = 'user'
u.store(self.db)
return u