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

Unified Diff: chrome/common/extensions/docs/server2/persistent_object_store_appengine.py

Issue 1151283007: Docserver overhaul: Gitiles away from me. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove inform_users template to fix presubmit failure (it's now a redirect) Created 5 years, 6 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
Index: chrome/common/extensions/docs/server2/persistent_object_store_appengine.py
diff --git a/chrome/common/extensions/docs/server2/persistent_object_store.py b/chrome/common/extensions/docs/server2/persistent_object_store_appengine.py
similarity index 66%
rename from chrome/common/extensions/docs/server2/persistent_object_store.py
rename to chrome/common/extensions/docs/server2/persistent_object_store_appengine.py
index c0ae8734c01cdaeab51f7c1ada93c1b8b2f35dd5..a2d0d5c9c30087b1804cfea1bca542a9fdcbb75e 100644
--- a/chrome/common/extensions/docs/server2/persistent_object_store.py
+++ b/chrome/common/extensions/docs/server2/persistent_object_store_appengine.py
@@ -2,23 +2,26 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-from appengine_wrappers import db
+import google.appengine.ext.db as db
+
from datastore_models import PersistentObjectStoreItem
from environment import IsDevServer
from future import All, Future
from object_store import ObjectStore
-class PersistentObjectStore(ObjectStore):
- '''Stores data persistently using the AppEngine Datastore API.
+class PersistentObjectStoreAppengine(ObjectStore):
+ '''Stores or retrieves persistent data using the AppEngine Datastore API.
'''
def __init__(self, namespace):
self._namespace = namespace
def SetMulti(self, mapping):
- rpcs = [db.put_async(
- PersistentObjectStoreItem.CreateItem(self._namespace, key, value))
- for key, value in mapping.iteritems()]
+ entities = [PersistentObjectStoreItem.CreateItem(
+ self._namespace, key, value)
+ for key, value in mapping.iteritems()]
+ # Some entites may be None if they were too large to insert. Skip those.
+ rpcs = [db.put_async(entity for entity in entities if entity)]
# If running the dev server, the futures don't complete until the server is
# *quitting*. This is annoying. Flush now.
if IsDevServer():
@@ -26,9 +29,8 @@ class PersistentObjectStore(ObjectStore):
return All(Future(callback=lambda: rpc.get_result()) for rpc in rpcs)
def GetMulti(self, keys):
- db_futures = dict(
- (k, db.get_async(
- PersistentObjectStoreItem.CreateKey(self._namespace, k)))
+ db_futures = dict((k, db.get_async(
+ PersistentObjectStoreItem.CreateKey(self._namespace, k)))
for k in keys)
def resolve():
return dict((key, future.get_result().GetValue())
@@ -40,7 +42,7 @@ class PersistentObjectStore(ObjectStore):
futures = []
for key in keys:
futures.append(db.delete_async(
- PersistentObjectStoreItem.CreateKey(self._namespace, key)))
+ PersistentObjectStoreItem.CreateKey(self._namespace, key)))
# If running the dev server, the futures don't complete until the server is
# *quitting*. This is annoying. Flush now.
if IsDevServer():

Powered by Google App Engine
This is Rietveld 408576698