def initialize(self): """ Initializes the instance with a mongodb database instance """ self.logger = get_logger('profile_handler') self._connection = get_mongodb_connection() self._db = self._connection[options.mongodb_name]
def read(self, request, id=None): conn = utils.get_mongodb_connection() db = conn[settings.MONGODB_DBNAME] if id: data = db["trials"].find_one({"_id": id}) else: data = list(db["trials"].find(limit=10)) return data
def initialize(self): """ Initializes the instance with a mongodn database instance :param db: an instance to pymongo database object """ self._logger = get_logger('lesson_handler') self._connection = get_mongodb_connection() self._db = self._connection[options.lesson_db]
def setUpClass(cls): cls.app = TestApp(app) cls.db = utils.get_mongodb_connection()[settings.MONGO_DB_NAME] cls.fs = GridFS(cls.db)
def __init__(self): self.connection = get_mongodb_connection() self._db = self.connection[options.auth_db] self.logger = get_logger('auth')
Rule('/<path:filename>'), ], converters={ 'ObjectId': ObjectIdConverter, }) @Request.application def app(request): urls = url_map.bind_to_environ(request.environ) try: endpoint, args = urls.match() except HTTPException, e: return e connection = get_mongodb_connection() try: return serve_request(request, connection, **args) except HTTPException as e: return e except: connection.close() if __name__ == '__main__': from werkzeug.serving import run_simple run_simple(settings.APP_HOST, settings.APP_PORT, app, use_debugger=settings.DEBUG, use_reloader=True)
def initialize(self): self.connection = get_mongodb_connection() self._db = self.connection[options.mongodb_name]
url_map = Map([ Rule('/<ObjectId:_id>'), ], converters={ 'ObjectId': ObjectIdConverter, }) @Request.application def app(request): urls = url_map.bind_to_environ(request.environ) try: endpoint, args = urls.match() except HTTPException, e: return e connection = get_mongodb_connection() try: return serve_request(request, connection, **args) except HTTPException as e: return e except: connection.close() if __name__ == '__main__': from werkzeug.serving import run_simple run_simple(settings.APP_HOST, settings.APP_PORT, app, use_debugger=settings.DEBUG, use_reloader=True)