Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PUT on resource #314

Closed
ebrehault opened this issue Jul 23, 2018 · 4 comments
Closed

PUT on resource #314

ebrehault opened this issue Jul 23, 2018 · 4 comments
Labels
enhancement GIP Guillotina Improvement Proposal

Comments

@ebrehault
Copy link
Member

At the moment (as far I can see), to modify an existing resource, the only option is a PATCH.

The problem is we cannot delete existing attributes or behaviors by patching.

So I guess PUT would be useful.

@bloodbare bloodbare added the GIP Guillotina Improvement Proposal label Jul 24, 2018
vangheem added a commit that referenced this issue Aug 29, 2018
@vangheem
Copy link
Member

initial implementation in 4.1.4

@ebrehault
Copy link
Member Author

Hi @vangheem, thank you for that.

I have a question though:

I have a folder with IAttachment behavior:

{"@id": "http://127.0.0.1:8080/db/c1/folder5", "@type": "Folder", "@name": "folder5", "@uid": "fe3|e589a5c8ff984ca8899deb8dd79a443d", "parent": {"@id": "http://127.0.0.1:8080/db/c1", "@name": "c1", "@type": "Container", "@uid": "fe3b0df173a14b4691fd93e692202c4a", "UID": "fe3b0df173a14b4691fd93e692202c4a"}, "is_folderish": true, "creation_date": "2018-08-30T19:37:53.071538+00:00", "modification_date": "2018-08-30T20:16:31.207804+00:00", "UID": "fe3|e589a5c8ff984ca8899deb8dd79a443d", "type_name": "Folder", "title": "Folder tt", "uuid": "fe3|e589a5c8ff984ca8899deb8dd79a443d", "__behaviors__": ["guillotina.behaviors.attachment.IAttachment"], "__name__": "folder5", "guillotina.behaviors.dublincore.IDublinCore": {"title": "Folder tt", "description": null, "creation_date": "2018-08-30T19:37:53.071538+00:00", "modification_date": "2018-08-30T20:16:31.207804+00:00", "effective_date": null, "expiration_date": null, "creators": [], "tags": null, "publisher": null, "contributors": ["root"]}, "guillotina.behaviors.attachment.IAttachment": {"file": null}, "items": [], "length": 0}

then I do a PUT where I remove the guillotina.behaviors.attachment.IAttachment attribute and I update the __behaviors__ value accordingly:

curl 'http://127.0.0.1:8080/db/c1/folder5' -X PUT -H 'Accept: application/json' -H 'Referer: http://localhost:4200/db/c1/folder5/@@edit' -H 'Origin: http://localhost:4200' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' -H 'Authorization: Basic cm9vdDpyb290' -H 'Content-Type: application/json' --data-binary '{"@id":"http://127.0.0.1:8080/db/c1/folder5","@type":"Folder","@name":"folder5","@uid":"fe3|e589a5c8ff984ca8899deb8dd79a443d","parent":{"@id":"http://127.0.0.1:8080/db/c1","@name":"c1","@type":"Container","@uid":"fe3b0df173a14b4691fd93e692202c4a","UID":"fe3b0df173a14b4691fd93e692202c4a"},"is_folderish":true,"creation_date":"2018-08-30T19:37:53.071538+00:00","modification_date":"2018-08-30T20:16:31.207804+00:00","UID":"fe3|e589a5c8ff984ca8899deb8dd79a443d","type_name":"Folder","title":"Folder tt","uuid":"fe3|e589a5c8ff984ca8899deb8dd79a443d","__behaviors__":[],"__name__":"folder5","guillotina.behaviors.dublincore.IDublinCore":{"title":"Folder tt","description":null,"creation_date":"2018-08-30T19:37:53.071538+00:00","modification_date":"2018-08-30T20:16:31.207804+00:00","effective_date":null,"expiration_date":null,"creators":[],"tags":null,"publisher":null,"contributors":["root"]},"items":[],"length":0}' --compressed

I get a proper 204 response, but the behavior is still there.

Is it expected?

If I update a value like the IDublinCore title, the change is properly saved, so I guess it is more a problem about updating behaviors manually.

It would be nice if it was possible, but if removing behaviors with a direct PUT on the resource is too difficult technically, maybe we should get an error status when trying to, instead of a 204.

@vangheem
Copy link
Member

Thanks Eric. I'll look into it--it's not too technically difficult. I'm just missing this part. Thanks for testing!

@vangheem vangheem reopened this Aug 30, 2018
@ebrehault
Copy link
Member Author

Fixed by #335

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement GIP Guillotina Improvement Proposal
Projects
None yet
Development

No branches or pull requests

3 participants