appengine-rest-server icon indicating copy to clipboard operation
appengine-rest-server copied to clipboard

Allow using key name (or integer ID) when referencing entities

Open GoogleCodeExporter opened this issue 9 years ago • 3 comments

It would be nice if there was an option to reference entities by key_name or by 
numeric ID, rather than key.

Keys are convenient for developers because they're unique and fast. But they're 
also long, which means they don't make the friendliest URLs.

It would be nice if I could tell appengine-rest-server what type of identifier 
to use when constructing (and interpreting) URLs. Perhaps this could be done as 
an additional parameter for Dispatcher.add_models, so this could be set on a 
per-model basis?

Original issue reported on code.google.com by [email protected] on 10 Jan 2013 at 9:45

GoogleCodeExporter avatar Mar 15 '15 00:03 GoogleCodeExporter

so you would imagine this as being a "static" option, as opposed to 
"per-request"?   maybe we could have a special prefix which identifies a 
key/numeric_id, e.g. "id~<key_or_numeric_id>"?  although you would still need a 
specific format for any returned values.  thoughts?

Original comment by [email protected] on 17 Jan 2013 at 2:43

GoogleCodeExporter avatar Mar 15 '15 00:03 GoogleCodeExporter

Original comment by [email protected] on 19 Jan 2013 at 1:56

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

GoogleCodeExporter avatar Mar 15 '15 00:03 GoogleCodeExporter

My original thought was that this would be a static option.

Normally each entity only has one "public" ID used to access it via URL, which 
is my reasoning here. It's definitely simpler that way, and leads to cleaner 
URLs.

If folks think that being able to dynamically switch between formats is useful, 
maybe there could be a default format which could be set via static 
configuration, and the special prefix could be used to override it if needed? 
That would cover both use cases.

Original comment by [email protected] on 19 May 2013 at 1:14

GoogleCodeExporter avatar Mar 15 '15 00:03 GoogleCodeExporter