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?

Categories

HOME
sonarqube
awk
forms
jmeter
gpu
datastore
zend-framework
mstest
devise
edge
settings
python-multithreading
jax-ws
vert.x
lanczos
sendgrid-api-v3
windows-ce
endpoint
comsol
null-pointer
firefox-addon
imessage
pyramid
sse
bourbon
replication
ag
cgbitmapcontext
backpack-for-laravel
systemtime
roundup
tiki-wiki
itunes
pylons
licensing
jackson-modules
8051
finagle
ntp
cognos-bi
quickfixj
laravel-eloquent
jett
processwire
engine.io
sharepoint-workflow
docfx
watchman
git-rewrite-history
unordered-map
apache-stanbol
ogc
apriori
lpsolve
contract
strftime
libgphoto2
opennms
video-conferencing
qtranslate
edit
css-transforms
smartfoxserver
tinkerpop3
uicolor
neon
freepbx
dbamp
toast
ascii-art
phonertc
binomial-theorem
doctype
dulwich
rdflib
skspritenode
omnifaces
sonarqube-5.0
unix-socket
kissfft
file-not-found
rfc5322
visual-studio-express
unit-of-work
observium
abstract-data-type
octal
mantle
stacky
redis-py
saleslogix
rmiregistry
objectquery
window-decoration
node-redis
flex-mobile
denied
multiplatform
delimited-text
qtabbar
build-environment
filesystemobject
strtod
purepdf
flvplayback

Resources

Encrypt Message