core.db.transport¶
Datastore transport layer: the process-wide client and the CRUD helpers.
Named database and namespace
The datastore client (__client__) is built once at import time and
kept for the whole process lifetime. Its target database and namespace come
from conf.db.name and
conf.db.namespace, which are sourced
from the VIUR_DB_NAME / VIUR_DB_NAMESPACE environment variables. Both
default to None — the standard (default) database and empty namespace —
so existing deployments are unaffected.
Because the client is created from the environment at import time, the target
cannot be retargeted at runtime: a single process always talks to exactly one
database. Key objects inherit that database and
namespace from the client, keeping every request on the configured target.
The legacy urlsafe key encoding (App Engine “Reference”) predates named
databases and only supports the default one. Therefore
Key.to_legacy_urlsafe
encodes a database-less copy of the key, and the client’s database is restored
on decoding — unambiguous precisely because the process is bound to a single
database.