本文整理汇总了Python中psycopg2cffi.compat.register方法的典型用法代码示例。如果您正苦于以下问题:Python compat.register方法的具体用法?Python compat.register怎么用?Python compat.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psycopg2cffi.compat
的用法示例。
在下文中一共展示了compat.register方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_admin_views
# 需要导入模块: from psycopg2cffi import compat [as 别名]
# 或者: from psycopg2cffi.compat import register [as 别名]
def init_admin_views(flask_app, database):
from psi.app.views import init_admin_views
try:
return init_admin_views(flask_app, database)
except sqlalchemy.exc.SQLAlchemyError as e:
# If we're running the flask utility script and Postgres
# isn't available, `init_admin_views` will raise an OperationalError,
# blocking the utility script from running. Instead, we catch the
# exception and warn the user so the user can invoke some of the
# commands that don't require database connections.
# TODO: don't require Postgres on app object initialization
log.exception(e)
log.warn('Cannot register admin views because of a SQLAlchemy error. '
'Skipping...')