本文整理汇总了Python中user.User.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_by_id方法的具体用法?Python User.get_by_id怎么用?Python User.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user.User
的用法示例。
在下文中一共展示了User.get_by_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: removeUserFollowing
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def removeUserFollowing(user_id_follower, user_id_following):
user_follower = User.get_by_id(user_id_follower)
user_following = User.get_by_id(user_id_following)
follow_query = Follow.all()
follow_query.filter("user_follower =", user_follower)
follow_query.filter("user_following =", user_following)
db.delete(follow_query.get())
示例2: isUserFollowing
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def isUserFollowing(user_id_follower, user_id_following):
user_follower = User.get_by_id(user_id_follower)
user_following = User.get_by_id(user_id_following)
follow_query = Follow.all()
follow_query.filter("user_follower =", user_follower)
follow_query.filter("user_following =", user_following)
is_follow = follow_query.get()
if(is_follow is not None):
return True
else:
return False
示例3: get_info
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def get_info(self, token):
"""
Returns user's info
:param token: Token which was returned by login method
:return dict user_info: Dictionary with users's info's
"""
user = User.get_by_id(token.userid)
return {"user_info": {"email": user.email, "display_name": user.display_name}}
示例4: YummyDone
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def YummyDone(user_id, post_id):
user_delete_yummy = User.get_by_id(user_id)
post_delete_yummy = Post.get_by_id(post_id)
yummy = Yummy.all()
yummy.filter("user =", user_delete_yummy)
yummy.filter("post =", post_delete_yummy)
if (len(yummy.fetch(1000)) > 0):
return True
else:
return False
示例5: get_by_user
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def get_by_user(cls, user_id, keys_only=False):
'''
Returns a list of all coupons
'''
user = User.get_by_id(user_id)
coupon_keys = user.held_coupons
if keys_only:
return coupon_keys
else:
return ndb.get_multi(coupon_keys)
示例6: initialize
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def initialize(self, *a, **kw):
webapp2.RequestHandler.initialize(self, *a, **kw)
uid = self.get_cookie('user_id')
if uid:
self.current_user = User.get_by_id(int(uid))
else:
self.current_user = None
if self.request.url.endswith('.json'):
self.format = 'json'
else:
self.format = 'html'
示例7: new_contact
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def new_contact(self, token, name, surname):
"""
Create new contact
:param token: which returned by user login
:param name: Name of the new contact
:param surname: Surname of the new Contact
:return:
"""
user = User.get_by_id(token.userid)
if not user:
return errors.UserDoesNotFound()
Contact.new_contact(user._id, name, surname)
return {}
示例8: get
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def get(self):
user_hash = self.request.cookies.get('user')
user_id = security.validate_hash(user_hash)
if user_id:
user = User.get_by_id(long(user_id))
if user:
self.response.out.write("Welcome, %s!" % html.escape(user.name))
else:
self.redirect("/unit4/signup")
else:
self.redirect("/unit4/signup")
示例9: toogleYummy
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def toogleYummy(user_id, post_id):
user_yummy = User.get_by_id(user_id)
post_yummy = Post.get_by_id(post_id)
if (not YummyDone(user_id, post_id)):
yummy = Yummy(user=user_yummy, post=post_yummy)
yummy.put()
return True
else:
yummy_delete = Yummy.all()
yummy_delete.filter("user =", user_yummy)
yummy_delete.filter("post =", post_yummy)
db.delete(yummy_delete.get())
return False
示例10: get
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def get(self):
code = self.request.get('code', '')
# TODO just use username returned from original request
acct = Imgur.Account.from_authorization_code(code)
if acct is None:
# If we couldn't retrieve the account, nothing more we can do here
return self.redirect('/')
user = User.get_by_id(acct.username)
if user is None:
User.create_user(acct.username, acct.access_token, acct.refresh_token, acct.access_expiration)
self.session['username'] = acct.username
return self.redirect('/')
示例11: removeAllUsersFollowers
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def removeAllUsersFollowers(user_id_following):
user_following = User.get_by_id(user_id_following)
follow_query = Follow.all()
follow_query.filter("user_following =", user_following)
db.delete(follow_query)
示例12: user
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def user(self):
if not hasattr(self, "_user"):
self._user = User.get_by_id(self.user_id)
return self._user
示例13: validate_name
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def validate_name(form, field):
user = User.get_by_id(current_user.id)
if not user.check_name(field.data):
raise ValidationError("Please pick another name.")
示例14: deleteYummysUser
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def deleteYummysUser(user_id):
yummys = Yummy.all().filter("user =", User.get_by_id(user_id))
db.delete(yummys)
示例15: initialize
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_by_id [as 别名]
def initialize(self, *a, **kw):
webapp2.RequestHandler.initialize(self, *a, **kw)
cookie = self.request.cookies.get('user')
uid = self.get_cookie(cookie)
self.user = uid and User.get_by_id(int(uid))