database_adapter.py 文件源码

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

项目:almanach 作者: internap 项目源码 文件源码
def database(function):
    def _connection(self, *args, **kwargs):
        try:
            if not self.db:
                connection = pymongo.MongoClient(config.mongodb_url(), tz_aware=True)
                self.db = connection[config.mongodb_database()]
                ensureindex(self.db)
            return function(self, *args, **kwargs)
        except KeyError as e:
            raise e
        except VolumeTypeNotFoundException as e:
            raise e
        except NotImplementedError as e:
            raise e
        except ConfigurationError as e:
            logging.exception("DB Connection, make sure username and password doesn't contain the following :+&/ "
                              "character")
            raise e
        except Exception as e:
            logging.exception(e)
            raise e

    return _connection
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号