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
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