本文整理汇总了Python中autonomie_base.models.base.DBSESSION.first方法的典型用法代码示例。如果您正苦于以下问题:Python DBSESSION.first方法的具体用法?Python DBSESSION.first怎么用?Python DBSESSION.first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autonomie_base.models.base.DBSESSION
的用法示例。
在下文中一共展示了DBSESSION.first方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_by_login
# 需要导入模块: from autonomie_base.models.base import DBSESSION [as 别名]
# 或者: from autonomie_base.models.base.DBSESSION import first [as 别名]
def find_by_login(cls, login, active=True):
query = DBSESSION().query(cls)
query = query.options(load_only('pwd_hash'))
query = query.filter_by(login=login)
if active:
query = query.filter_by(active=True)
return query.first()
示例2: get_by_internal_id
# 需要导入模块: from autonomie_base.models.base import DBSESSION [as 别名]
# 或者: from autonomie_base.models.base.DBSESSION import first [as 别名]
def get_by_internal_id(cls, internal_id):
query = DBSESSION().query(cls.id).filter_by(internal_id=internal_id)
query = query.first()
if query is not None:
result = query[0]
else:
result = None
return result
示例3: get_next_order
# 需要导入模块: from autonomie_base.models.base import DBSESSION [as 别名]
# 或者: from autonomie_base.models.base.DBSESSION import first [as 别名]
def get_next_order(cls):
"""
:returns: The next available order
:rtype: int
"""
query = DBSESSION().query(func.max(cls.order)).filter_by(active=True)
query = query.first()
if query is not None and query[0] is not None:
result = query[0] + 1
else:
result = 0
return result
示例4: get_next_order
# 需要导入模块: from autonomie_base.models.base import DBSESSION [as 别名]
# 或者: from autonomie_base.models.base.DBSESSION import first [as 别名]
def get_next_order(cls):
"""
:returns: The next available order
:rtype: int
"""
query = DBSESSION().query(func.max(cls.order)).filter_by(active=True)
query = query.filter_by(
type_=cls.__mapper_args__['polymorphic_identity']
)
query = query.first()
if query is not None and query[0] is not None:
result = query[0] + 1
else:
result = 0
return result
示例5: get_next_order_by_category
# 需要导入模块: from autonomie_base.models.base import DBSESSION [as 别名]
# 或者: from autonomie_base.models.base.DBSESSION import first [as 别名]
def get_next_order_by_category(cls, category_id):
"""
:param int category_id: The id of the category to check for
:returns: The next order available in types from the given category
:rtype: int
"""
query = DBSESSION().query(func.max(cls.order)).filter_by(
category_id=category_id
).filter_by(active=True)
query = query.first()
if query is not None and query[0] is not None:
result = query[0] + 1
else:
result = 0
return result
示例6: last
# 需要导入模块: from autonomie_base.models.base import DBSESSION [as 别名]
# 或者: from autonomie_base.models.base.DBSESSION import first [as 别名]
def last(cls, grid_class, company_id):
query = DBSESSION().query(grid_class).filter_by(company_id=company_id)
query = query.order_by(desc(grid_class.date))
return query.first()