本文整理汇总了Python中models.factory.PosGraduationFactory.post_graduations_dao方法的典型用法代码示例。如果您正苦于以下问题:Python PosGraduationFactory.post_graduations_dao方法的具体用法?Python PosGraduationFactory.post_graduations_dao怎么用?Python PosGraduationFactory.post_graduations_dao使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.factory.PosGraduationFactory
的用法示例。
在下文中一共展示了PosGraduationFactory.post_graduations_dao方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import post_graduations_dao [as 别名]
def get(nick, authenticated=False):
"""Return an User from database. If failed, None."""
try:
condition = {'users.nick': nick}
pfactory = PosGraduationFactory()
dao = pfactory.post_graduations_dao()
program = list(dao.find(condition))
if program:
initials = program[0]['initials']
else:
return None
for user in program[0]['users']:
if nick.lower() == user['nick'].lower():
found_user = User()
found_user._nick = user['nick']
found_user._pg_initials = initials.lower()
found_user._full_name = user['fullName']
found_user._role = user['role']
found_user._email = user['email']
found_user._token = user['token']
found_user.__is_authenticated = authenticated
found_user.__is_active = True
found_user.__is_anonymous = False
return found_user
return None
except (TypeError, AttributeError):
return None
示例2: get_std_for_template
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import post_graduations_dao [as 别名]
def get_std_for_template(post_graduation, give_me_empty=False):
"""
Return default template stuff for jinja to render.
Freely put None if theres no post_graduation dict.
But if there's one, must be the found by DAOs
and requested by user.
Must be called like this in every template:
return render_template('MYTEMPLATE.html', std=get_std_for_template(None), ...)
That said, there will always be a std dict in jinja environments.
Jinja will have following template vars, if you called it right:
std.post_graduation (dict for current given post graduation)
std.post_graduations_registered (dict for the post graduations available at minerva)
std.post_graduations_unregistered (dict for post graduations unavailable at minerva)
They can be None if nothing has found from database or provided by function args.
Jinja will have the following template vars, if you called it with give_me_empty=True:
std.post_graduation == None
std.post_graduations_registered == []
std.post_graduations_unregistered == []
"""
if give_me_empty:
return {
'post_graduation': None,
'post_graduations_registered': [],
'post_graduations_unregistered': [],
}
else:
pfactory = PosGraduationFactory()
post_graduations_registered = pfactory.post_graduations_dao().find({'isSignedIn': True})
post_graduations_unregistered = pfactory.post_graduations_dao().find({'isSignedIn': False})
return {
'post_graduation': post_graduation,
'post_graduations_registered': post_graduations_registered,
'post_graduations_unregistered': post_graduations_unregistered,
}