orm.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:fleaker 作者: croscon 项目源码 文件源码
def _find_db_ext():
    """Find the current ORM Extension this App is using.

    After we discover and initialize the proper ORM Extension we need the
    ``db`` proxy to resolve to it, which is exactly what this method does here.

    Does this by simply inspecting a global, but that could be done better.

    Returns:
        flask_utils.FlaskDB|flask_sqlalchemy.SQLAlchemy: The correct and
            current ORM Extension in use for this App.
    """
    if _SELECTED_BACKEND is MISSING:
        # @TODO: Do like Flask does with the context error and have a single
        # leading line that sort of explains the issue and is easily searched?
        raise RuntimeError("You have attempted to use the Fleaker DB proxy "
                           "before it was initialized! Please ensure you are "
                           "in the right context or push it yourself! Please "
                           "see the documentation for more information!")
    return _SELECTED_BACKEND
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号