예제 #1
0
 def _update_one(self, resource: Resource) -> None:
     data = as_json(resource, expanded=False, store_metadata=False, model_context=None,
                    metadata_context=None, context_resolver=None)
     try:
         record = self.service.update(data)
     except StoreLibrary.RecordMissing:
         raise UpdatingError("resource not found")
     except StoreLibrary.RecordDeprecated:
         raise UpdatingError("resource is deprecated")
     else:
         resource._store_metadata = wrap_dict(record["metadata"])
예제 #2
0
 def _update_one(self, resource: Resource, schema_id: str) -> None:
     context = self.model_context or self.context
     data = as_jsonld(resource, "compacted", False, model_context=context, metadata_context=None,
                      context_resolver=self.service.resolve_context, na=nan)
     params_update = copy.deepcopy(self.service.params.get("update", {}))
     params_update["rev"] = resource._store_metadata._rev
     schema = quote_plus(schema_id) if schema_id else "_"
     url = f"{self.service.url_resources}/{schema}/{quote_plus(resource.id)}"
     try:
         response = requests.put(url, headers=self.service.headers,
                                 data=json.dumps(data, ensure_ascii=True), params=params_update)
         response.raise_for_status()
     except HTTPError as e:
         raise UpdatingError(_error_message(e))
     else:
         self.service.sync_metadata(resource, response.json())
예제 #3
0
 def _update_one(self, resource: Resource) -> None:
     context = self.model_context or self.context
     data = as_jsonld(resource,
                      "compacted",
                      False,
                      model_context=context,
                      metadata_context=None,
                      context_resolver=self.service.resolve_context)
     rev = {"rev": resource._store_metadata._rev}
     url = f"{self.service.url_resources}/_/{quote_plus(resource.id)}"
     try:
         response = requests.put(url,
                                 headers=self.service.headers,
                                 data=json.dumps(data, ensure_ascii=True),
                                 params=rev)
         response.raise_for_status()
     except HTTPError as e:
         raise UpdatingError(_error_message(e))
     else:
         self.service.sync_metadata(resource, response.json())