本文整理汇总了Python中model.User.get_public_properties方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_public_properties方法的具体用法?Python User.get_public_properties怎么用?Python User.get_public_properties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.get_public_properties方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_public_properties [as 别名]
def get(self, username):
"""Loads user's properties. If logged user is admin it loads also non public properties"""
if auth.is_admin():
properties = User.get_private_properties()
else:
properties = User.get_public_properties()
traveler_key = getattr(g.user_db,'fellow_traveler',None)
if traveler_key:
traveler = traveler_key.get()
future=False
else:
traveler = model.FellowTraveler.create_or_update(
name=g.user_db.name,
email=g.user_db.email,
avatar_url=g.user_db.avatar_url,
parent=g.user_db.key,
added_by=g.user_db.key)
traveler_key =traveler.put()
traveler.key = traveler_key
g.user_db.fellow_traveler = traveler_key
future = g.user_db.put_async()
db_dict = g.user_db.to_dict(include=properties)
db_dict["fellow_traveler"] = traveler.to_dict(include=model.FellowTraveler.get_public_properties())
if future:
future.get_result()
return db_dict
示例2: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_public_properties [as 别名]
def get(self, username):
"""Loads user's properties. If logged user is admin it loads also non public properties"""
if auth.is_admin():
properties = User.get_private_properties()
else:
properties = User.get_public_properties()
return g.user_db.to_dict(include=properties)
示例3: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_public_properties [as 别名]
def get(self):
parser = reqparse.RequestParser()
parser.add_argument("cursor", type=ArgumentValidator.create("cursor"))
args = parser.parse_args()
users_future = User.query().order(-User.created).fetch_page_async(10, start_cursor=args.cursor)
total_count_future = User.query().count_async(keys_only=True)
users, next_cursor, more = users_future.get_result()
users = [u.to_dict(include=User.get_public_properties()) for u in users]
return make_list_response(users, next_cursor, more, total_count_future.get_result())
示例4: put
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_public_properties [as 别名]
def put(self, key):
"""Updates user's properties"""
update_properties = ['name', 'bio', 'email', 'location', 'avatar_url', 'facebook', 'github',
'gplus', 'linkedin', 'twitter', 'instagram']
if auth.is_admin():
update_properties += ['verified', 'active', 'admin']
new_data = _.pick(request.json, update_properties)
g.model_db.populate(**new_data)
g.model_db.put()
#return make_empty_ok_response()
if auth.is_admin():
properties = User.get_private_properties()
else:
properties = User.get_public_properties()
return g.model_db.to_dict(include=properties)