def get(self, objectName=None): response = handle_mongo_result((yield gen.Task( self.db.connection(collectionname=objectName).find))) print response response = simplejson.dumps(response, default=default) print response self.finish(response)
def post(self, objectName=None): vo = {} vo['object_name'] = objectName records = yield gen.Task(self.db.stores.find, vo) if len(records[0][0]) == 0: response = yield gen.Task(self.db.stores.insert,vo) app = self.params response = handle_mongo_result((yield gen.Task( self.db.connection(collectionname=objectName).insert, app))) self.finish('{"code": 200, "message": "object saved!"}')