本文整理汇总了Python中autonomie_base.models.base.DBSESSION.join方法的典型用法代码示例。如果您正苦于以下问题:Python DBSESSION.join方法的具体用法?Python DBSESSION.join怎么用?Python DBSESSION.join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autonomie_base.models.base.DBSESSION
的用法示例。
在下文中一共展示了DBSESSION.join方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: query
# 需要导入模块: from autonomie_base.models.base import DBSESSION [as 别名]
# 或者: from autonomie_base.models.base.DBSESSION import join [as 别名]
def query(self):
"""
Return the main query for our list view
"""
logger.debug("Queryiing")
query = DBSESSION().query(distinct(User.id), User)
query = query.join(User.login)
return query.outerjoin(User.companies)
示例2: active_company_ids
# 需要导入模块: from autonomie_base.models.base import DBSESSION [as 别名]
# 或者: from autonomie_base.models.base.DBSESSION import join [as 别名]
def active_company_ids(self):
"""
Return only enabled companies ids
"""
from autonomie.models.company import Company
query = DBSESSION().query(COMPANY_EMPLOYEE.c.company_id)
query = query.filter(COMPANY_EMPLOYEE.c.account_id == self.id)
query = query.join(Company).filter(Company.active == True)
return [c[0] for c in query]
示例3: get_users_options
# 需要导入模块: from autonomie_base.models.base import DBSESSION [as 别名]
# 或者: from autonomie_base.models.base.DBSESSION import join [as 别名]
def get_users_options(roles=None):
"""
Return the list of active users from the database formatted as choices:
[(user_id, user_label)...]
:param role: roles of the users we want
default: all
values : ('contractor', 'manager', 'admin'))
"""
query = DBSESSION().query(User).options(
load_only('id', 'firstname', 'lastname')
)
# Only User accounts with logins
query = query.join(Login).filter(Login.active == True)
query = query.order_by(User.lastname)
if roles and not hasattr(roles, "__iter__"):
roles = [roles]
query = _filter_by_group(query, roles)
return [(unicode(u.id), format_account(u)) for u in query]