Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Unified Diff: impl/prod/info.go

Issue 1253263002: Make rawdatastore API safer for writing filters. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix comments Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « impl/prod/datastore_key.go ('k') | impl/prod/raw_datastore.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/prod/info.go
diff --git a/impl/prod/info.go b/impl/prod/info.go
index c860bc0095bb03138b01a7f74981b5bdce385555..f513f3b04458cbc70720058561634d0b532a34da 100644
--- a/impl/prod/info.go
+++ b/impl/prod/info.go
@@ -12,9 +12,15 @@ import (
"google.golang.org/appengine"
)
+type key int
+
+var namespaceCopyKey key
+
// useGI adds a gae.GlobalInfo implementation to context, accessible
// by gae.GetGI(c)
func useGI(c context.Context) context.Context {
+ // TODO(iannucci): make a better way to get the initial namespace?
+ c = context.WithValue(c, namespaceCopyKey, "")
return info.SetFactory(c, func(ci context.Context) info.Interface {
return giImpl{ci}
})
@@ -28,6 +34,9 @@ func (g giImpl) AccessToken(scopes ...string) (token string, expiry time.Time, e
func (g giImpl) AppID() string {
return appengine.AppID(g)
}
+func (g giImpl) GetNamespace() string {
+ return g.Value(namespaceCopyKey).(string)
+}
func (g giImpl) Datacenter() string {
return appengine.Datacenter(g)
}
@@ -53,7 +62,11 @@ func (g giImpl) ModuleName() (name string) {
return appengine.ModuleName(g)
}
func (g giImpl) Namespace(namespace string) (context.Context, error) {
- return appengine.Namespace(g, namespace)
+ c, err := appengine.Namespace(g, namespace)
+ if err != nil {
+ return c, err
+ }
+ return context.WithValue(c, namespaceCopyKey, namespace), nil
}
func (g giImpl) PublicCertificates() ([]info.Certificate, error) {
certs, err := appengine.PublicCertificates(g)
« no previous file with comments | « impl/prod/datastore_key.go ('k') | impl/prod/raw_datastore.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698