Closed aparajita closed 12 years ago
Can you create a test for this please too? Which fails before your patch and succeeds after it?
Does the same happen for EmbeddedListResource
? Yes? No? Why not?
Thanks for help!
Can you create a test for this please too? Which fails before your patch and succeeds after it?
Sure.
Does the same happen for
EmbeddedListResource
? Yes? No? Why not?
Haven't tried.
BTW, is this ticket properly named? I do not think we have EmbeddedSortedListResource? Can you be more precise in description?
The class changes are welcome, but the fixes in this commit are necessary to be able to create embedded documents in a list.
Yes. Getting to there too. :-)
Tests would help a lot.
Something like this after line 120 of test_basic.py:
response = self.c.post(embeddedlistfieldtest_uri + 'embedded list/', '{"name": "Embedded person 3"}', content_type='application/json')
self.assertEqual(response.status_code, 201)
Then add:
self.assertEqual(response['embeddedlist'][2]['name'], 'Embeded person 3')
after line 127.
Can you please sign-off this pull request?
Please note item (e).
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
(e) Being forced to include this DCO is a real pain in the neck and
discourages me from making further contributions.
Signed-off-by: Aparajita Fishman aparajita@aparajita.com
Bah, you can just put the signed-off line/comment, no putting all that there. And interesting (e). ;-)
Anyway, thanks. Now I started working on subresources. Yes, it seems it is buggy. ;-)
OK. Now things should work on subresource. Some things are not yet supported and will probably blow (bulk operations, filtering, sorting). Also set operations could be supported in theory.
I am a bit concerned with non-atomicity of all this. This should probably be done in Mongoengine, so that object updates (from PATCH) would be done in an atomic manner. Current fetch-update-save cycle could probably lead to data loss. So POST is OK by definition, PUT probably too. But DELETE and PATCH could do bad things.
Even worse is for subresources (lists), especially because we use indexes so things could move around and something would not be anymore on its place. You want to delete n-th element, but that element could be already something else at the time it is processed. POST could work here better, currently it could still remove things.
I am a bit concerned with non-atomicity of all this.
Then I guess you may have to override the tastypie save methods.
Currently, POSTing to an EmbeddedSortedListResource saves the resource, but then generates an exception because the get_resource_uri fails. This commit does the following to fix that: