-
Notifications
You must be signed in to change notification settings - Fork 120
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
add resource name in a string #44
Comments
Not a slumber dev, but I think this would be hard to do. Given slumber’s simple principle of converting Python attributes to URI path segments and using a call for invalid syntax (like integers), your solution sounds like the way to go. IOW, I think base.thing('hyphen-dash').get() is as good as base.things(42).get() In the spirit of OO path manipulation libraries, you could make the case for new syntax like base / things / 'hyphen-dash' and base / things / 42, i.e. overriding the division operator, but this looks more cute/wrong to me. |
This would be possible to do if the base API object became a resource in it's own right, then you could do api("pdus-oid2").post() and such, however I'm not sure offhand how that world behind that, api("pdus-oid2")(25).delete() looks kinda gnarly to me and non obvious. I'm not particully able to have the time to implement this, but if you brought API inline with Resource in this capacity I would probably be willing to accept it. |
After I have wandered to this page, I have found my solution to this problem. Using
works for me just fine. |
Now I have found even better (much more readable) solution:
It also solves problem with API endpoints on reserved keywords like |
My resource name contains hyphens (-). I can only use underscore (_) character for a name in Python. I do a hack like this:
PATH = 'http://localhost:8000/api/v1/' # (the real url should be: http://localhost:8000/api/v1/conf/)
response_post = api.conf("pdus-oid2").post(pdu.dict)
response_delete = api.conf("pdus-oid2/" + response_post["_id"]).delete()
whereas "pdus-oid2" is the name of the resource. Thus, I reckon you should add a possibility of adding a resource name in a string.
The text was updated successfully, but these errors were encountered: