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

Unified Diff: dashboard/dashboard/common/namespaced_stored_object.py

Issue 2748953003: . Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: Created 3 years, 9 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 | « no previous file | dashboard/dashboard/common/stored_object.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dashboard/dashboard/common/namespaced_stored_object.py
diff --git a/dashboard/dashboard/common/namespaced_stored_object.py b/dashboard/dashboard/common/namespaced_stored_object.py
index 685a96f89540113531e1a9cbe128aa9b5d7be170..cad1b5fc426da3e62c037dae0e354bbb0d354f72 100644
--- a/dashboard/dashboard/common/namespaced_stored_object.py
+++ b/dashboard/dashboard/common/namespaced_stored_object.py
@@ -4,40 +4,77 @@
"""A wrapper for stored_object that separates internal and external."""
+from google.appengine.ext import ndb
+
from dashboard.common import datastore_hooks
from dashboard.common import stored_object
+@ndb.synctasklet
def Get(key):
"""Gets either the external or internal copy of an object."""
+ result = yield GetAsync(key)
+ raise ndb.Return(result)
+
+
+@ndb.tasklet
+def GetAsync(key):
namespaced_key = _NamespaceKey(key)
- return stored_object.Get(namespaced_key)
+ result = yield stored_object.GetAsync(namespaced_key)
+ raise ndb.Return(result)
+@ndb.synctasklet
def GetExternal(key):
"""Gets the external copy of a stored object."""
+ result = yield GetExternalAsync(key)
+ raise ndb.Return(result)
+
+
+@ndb.tasklet
+def GetExternalAsync(key):
namespaced_key = _NamespaceKey(key, datastore_hooks.EXTERNAL)
- return stored_object.Get(namespaced_key)
+ result = yield stored_object.GetAsync(namespaced_key)
+ raise ndb.Return(result)
+@ndb.synctasklet
def Set(key, value):
"""Sets the the value of a stored object, either external or internal."""
+ yield SetAsync(key, value)
+
+
+@ndb.tasklet
+def SetAsync(key, value):
namespaced_key = _NamespaceKey(key)
- stored_object.Set(namespaced_key, value)
+ yield stored_object.SetAsync(namespaced_key, value)
+@ndb.synctasklet
def SetExternal(key, value):
"""Sets the external copy of a stored object."""
+ yield SetExternalAsync(key, value)
+
+
+@ndb.tasklet
+def SetExternalAsync(key, value):
namespaced_key = _NamespaceKey(key, datastore_hooks.EXTERNAL)
- stored_object.Set(namespaced_key, value)
+ yield stored_object.SetAsync(namespaced_key, value)
+@ndb.synctasklet
def Delete(key):
"""Deletes both the internal and external copy of a stored object."""
+ yield DeleteAsync(key)
+
+
+@ndb.tasklet
+def DeleteAsync(key):
internal_key = _NamespaceKey(key, namespace=datastore_hooks.INTERNAL)
external_key = _NamespaceKey(key, namespace=datastore_hooks.EXTERNAL)
- stored_object.Delete(internal_key)
- stored_object.Delete(external_key)
+ yield (
+ stored_object.DeleteAsync(internal_key),
+ stored_object.DeleteAsync(external_key))
def _NamespaceKey(key, namespace=None):
« no previous file with comments | « no previous file | dashboard/dashboard/common/stored_object.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698