def run(self, document_id): """ This method is called by Celery, and should not be overridden. It will call the `process` method with a dictionary containing all the document information and will update de database with results. """ document = MongoDictAdapter(doc_id=document_id, host=config.MONGODB_CONFIG['host'], port=config.MONGODB_CONFIG['port'], database=config.MONGODB_CONFIG['database']) # Create a dictionary out of our document. We could simply pass # it on to the process method, but for now we won't let the user # manipulate the MongoDict directly. dic = {k: v for k, v in document.iteritems()} result = self.process(dic) document.update(result) return document_id