def open_gridfs(): for collection in ('avatars',): def set_fs(fs, error): if error: raise error global fss fss[collection] = GridFSWrapper(fs, collection) motor.MotorGridFS(get_db(), collection=collection).open(set_fs)
def open_gridfs(): for collection in ('avatars', ): def set_fs(fs, error): if error: raise error global fss fss[collection] = GridFSWrapper(fs, collection) motor.MotorGridFS(get_db(), collection=collection).open(set_fs)
def __getattr__(self, db_method): if self.collection is None: self.collection = get_db(self.collection_name) method = getattr(self.collection, db_method) def fn(*args, **kwargs): #print 'method',db_method,args,kwargs f = method(*args, **kwargs) if isinstance(f, Future): return fudef(f) return f return fn
def fn(*args, **kwargs): d = get_db(self.collection_name) d.addCallback( lambda collection: getattr(collection, db_method)(*args, **kwargs)) return d