Пример #1
0
    def collection(self):
        if not self.collection_name:
            self.collection_name = '{}'.format(
                self.model_class.__name__.lower())

        if not self._collection:
            db = ConnectionManager.get_database(self.db_name)
            if not db:
                raise ConnectionFailure('No connection for {}'.format(
                    self.db_name))
            self._collection = getattr(db, self.collection_name)
        return self._collection
Пример #2
0
    def collection(self):
        if not self.collection_name:
            self.collection_name = '{}'.format(
                self.model_class.__name__.lower())

        if not self._collection:
            db = ConnectionManager.get_database(self.db_name)
            if not db:
                raise ConnectionFailure(
                    'No connection for {}'.format(self.db_name))
            self._collection = getattr(db, self.collection_name)
        return self._collection