예제 #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
파일: collection.py 프로젝트: gukoff/ognom
    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