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

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

Issue 10825067: Extensions Docs Server: Apps samples page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: less is_apps and fixes Created 8 years, 4 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/blob_reference_store.py
diff --git a/chrome/common/extensions/docs/server2/blob_reference_store.py b/chrome/common/extensions/docs/server2/blob_reference_store.py
new file mode 100644
index 0000000000000000000000000000000000000000..97c68273028fec76bd7c66db3c47efe07a6fa510
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/blob_reference_store.py
@@ -0,0 +1,41 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# 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
+from appengine_wrappers import BlobReferenceProperty
+
+BLOB_REFERENCE_BLOBSTORE = 'BlobReferenceBlobstore'
+
+class _Model(db.Model):
+ key_ = db.StringProperty()
+ value = BlobReferenceProperty()
+
+class BlobReferenceStore(object):
+ """A wrapper around the datastore API that can store blob keys.
+ """
+ def __init__(self, branch):
+ self._branch = branch
+
+ def _Query(self, namespace, key):
+ return _Model.gql('WHERE key_ = :1', self._MakeKey(namespace, key)).get()
+
+ def _MakeKey(self, namespace, key):
+ return '.'.join([self._branch, namespace, key])
+
+ def Set(self, namespace, key, value):
+ _Model(key_=self._MakeKey(namespace, key), value=value).put()
+
+ def Get(self, namespace, key):
+ result = self._Query(namespace, key)
+ if not result:
+ return None
+ return result.value
+
+ def Delete(self, namespace, key):
+ result = self._Query(namespace, key)
+ if not result:
+ return None
+ blob_key = result.value
+ result.delete()
+ return blob_key

Powered by Google App Engine
This is Rietveld 408576698