google-app-engine
Remove appid (& namespace) from Key string
A string representation of entity's key always have app-id & namespace as a prefix. But in most case they are not required because too obvious. ex> Key : ag13YXJjbG91ZC10ZXN0chsLEgVGb3JjZRihnAEMCxIIVW5pdFNsb3QYAgw after removing appid_namespace part : chsLEgVGb3JjZRihnAEMCxIIVW5pdFNsb3QYAgw I know (kind,id or name) pair can be another solution for identifying unique entity but here, I just want to know how to eliminate app-id & namespace prefix and expose rest as a part of REST API... How can I remove them?
Hey, I'm not sure how you want your REST api to work, but if you do something like from google.appengine.ext import db def getRESTPath (entity): def addKeyPathRecursive (key): restPaths.append('%s/%s' % (key.kind(), key.id_or_name())) parentKey = key.parent() if parentKey: addKeyPathRecursive(parentKey) restPaths = [] addKeyPathRecursive(entity.key()) return '/'.join(reversed(restPaths)) class Grandpa(db.Model): pass class Papa(db.Model): pass class Kid(db.Model): pass kid = Kid(parent = Papa(parent = Grandpa().put()).put()) kid.put() print getRESTPath(kid) you get a string like Grandpa/21386/Papa/21387/Kid/21388. If you just want (kind, id_or_name) without the ancestor path, I'm not sure why you're unhappy with '%s/%s' % (key.kind(), key.id_or_name()). You can't remove namespace info from the way the datastore treats keys internally, but that doesn't mean you have to display it to users.
Related Links
Google App Engine - Issue with creating a bulkloading config
Solr Timeout error even data is instered
Why does BigQuery fail to parse an Avro file that is accepted by avro-tools?
Insufficient Permission with Appengine Flex service account to access Drive folder
Getting Invalid Key message thrown when creating child records
Where do I find the pricing for the different frontend instance types?
Missing index on specific entities in app engine
Get current deployed timestamp in AppEngine/Go
Jersey throwing exception in Google App Engine
Uploading >10k files as static content to GAE
Dealing with large zip uploads and extracting using google cloud
Android Studio not recognizing gradle 2.10
How to solving ImportError: No module named scraping
Securely providing external service credentials to Google App Engine?
Arduino make GET request to Google app engine
Is my GAE Search corrupt?