def normalize_db(self, data): try: news = QueryNewsModel.objects.get( id=data['id'] ) news.update( version=data.get('version', news.version), title=data.get('title', news.title), content=data.get('content', news.content), author=data.get('author', news.author), published_at=data.get('published_at', news.published_at), tags=data.get('tags', news.tags), ) news.reload() except mongoengine.DoesNotExist: QueryNewsModel( id=data['id'], version=data['version'], title=data.get('title'), content=data.get('content'), author=data.get('author'), tags=data.get('tags'), ).save() except Exception as e: return e
id=data['id'] ) news.update( version=data.get('version', news.version), title=data.get('title', news.title), content=data.get('content', news.content), author=data.get('author', news.author), published_at=data.get('published_at', news.published_at), tags=data.get('tags', news.tags), ) news.reload() except mongoengine.DoesNotExist: QueryNewsModel( id=data['id'], version=data['version'], title=data.get('title'), content=data.get('content'), author=data.get('author'), tags=data.get('tags'), ).save() except Exception as e: return e #crear los puntos de acceso para los datos de QueryStack. Primero, cree la búsqueda de ID. Escribamos un método get_news que tenga un decorador RPC de Nameko. Dentro del método get_news, no hay complejidad; simplemente usaremos MongoEngine para buscar Noticias usando el ID único como referencia @rpc def get_news(self, id): try: news = QueryNewsModel.objects.get(id=id) return news.to_json() except mongoengine.DoesNotExist as e: return e except Exception as e: