Closed GoogleCodeExporter closed 9 years ago
A little more details:
Consider something like a bookmarking service that has urls and a list of tags
(of type Tag).
The Model:
def Bookmark(db.Model):
url = db.StringProperty()
tags = db.ListProperty(db.Key)
The RESTful call:
http://localhost:8080/rest/Bookmark/abcdefgh012345/tags/
returns
[datastore_types.Key.from_path(u'Tag', 2, _app=u'my-project'),
datastore_types.Key.from_path(u'Tag', 6, _app=u'my-project')]
instead of a list of two Tag objects
Original comment by michael....@gmail.com
on 10 Apr 2011 at 12:38
i'm not sure i understand the issue. are you saying that the keys are not
appearing correctly, or that you want the actual Model objects instead of the
keys? if the former, that's a bug. if the latter, that is by design.
Original comment by jahlborn@gmail.com
on 10 Apr 2011 at 1:23
It's both, I guess.
The keys are not appearing correctly, as you can see above.
The REST service should not return
[datastore_types.Key.from_path(u'Tag', 2, _app=u'my-project'),
datastore_types.Key.from_path(u'Tag', 6, _app=u'my-project')]
But also, I would like to get the actual Model objects if I query for list
parameters. As far as I understand, it's standard behavior for a RESTful
service that nested models can be retrieved like that.
Or is there another way to get to those nested objects apart from sending a
request to the server querying for the object by key one-by-one?
Original comment by michael....@gmail.com
on 10 Apr 2011 at 1:28
well, i don't claim that this service is 100% RESTful, as that's a difficult
target. the truly RESTful way is that every object includes complete urls to
reference other objects. instead, this service returns keys (which can be
trivially converted to urls) which can be used to retrieve referenced objects.
so, there does seem to be a bug in that the keys are returned incorrectly. but
otherwise, i think that returning the keys is correct RESTful behavior.
Original comment by jahlborn@gmail.com
on 10 Apr 2011 at 2:47
I see. Thanks for the reply. Would you consider that an extension anytime in
the future? You seem to have everything in place already (the handlers etc.),
so the missing piece would be adding that one level of recursion.
In any case, thanks for taking care of that bug.
Original comment by michael....@gmail.com
on 10 Apr 2011 at 3:29
yeah, i was thinking maybe you could include something in the url which
indicates that you want to "dereference" the keys instead of just returning
them. interesting idea.
Original comment by jahlborn@gmail.com
on 10 Apr 2011 at 6:30
That sounds like a great suggestion! Looking forward to something like that.
Original comment by michael....@gmail.com
on 10 Apr 2011 at 6:38
split the enhancement request out into a separate issue, issue 30.
Original comment by jahlborn@gmail.com
on 10 Apr 2011 at 11:56
This issue was closed by revision r58.
Original comment by jahlborn@gmail.com
on 10 May 2011 at 1:00
This will now return an xml/json list as appropriate to the accept header.
additionally, i added support for retrieving an individual element of the list
using the syntax "<model>/<key>/<property>/<index>" (note, this will still
return the key _value_, haven't figured out the best way to add support for
dereferencing the keys yet).
Original comment by jahlborn@gmail.com
on 10 May 2011 at 2:28
Original comment by jahlborn@gmail.com
on 6 Jun 2012 at 1:10
Original issue reported on code.google.com by
michael....@gmail.com
on 10 Apr 2011 at 12:04