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

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

Issue 10825067: Extensions Docs Server: Apps samples page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Samples on API pages 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/appengine_datastore.py
diff --git a/chrome/common/extensions/docs/server2/appengine_datastore.py b/chrome/common/extensions/docs/server2/appengine_datastore.py
new file mode 100644
index 0000000000000000000000000000000000000000..aa5882d63e48f4e96f59e694f94a88efc2f9d00f
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/appengine_datastore.py
@@ -0,0 +1,40 @@
+# 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
+
+DATASTORE_BLOBSTORE = 'DatastoreBlobstore'
+
+class _Model(db.Model):
+ key_ = db.StringProperty()
+ value = BlobReferenceProperty()
+
+class AppEngineDatastore(object):
+ """A wrapper around the datastore API that can store blob keys.
not at google - send to devlin 2012/08/09 07:52:36 AppEngineDatastore is kind of a generic name to be
cduvall 2012/08/09 19:20:08 Done.
+ """
+ def __init__(self, branch):
+ self._branch = branch
+
not at google - send to devlin 2012/08/09 07:52:36 nit: def _MakeKey(self, namespace, key): return
cduvall 2012/08/09 19:20:08 Done.
+ def _Query(self, key, namespace):
+ result = _Model.gql('WHERE key_ = :1',
+ key + '.' + self._branch + '.' + namespace).get()
+ if not result:
+ return None
+ return result
not at google - send to devlin 2012/08/09 07:52:36 return result? Or just return _Model.gql...
cduvall 2012/08/09 19:20:08 Done.
+
+ def Set(self, key, value, namespace):
not at google - send to devlin 2012/08/09 07:52:36 namespace is part of the key, right? So it go befo
cduvall 2012/08/09 19:20:08 Done.
+ _Model(key_=key + '.' + self._branch + '.' + namespace, value=value).put()
+
+ def Get(self, key, namespace):
not at google - send to devlin 2012/08/09 07:52:36 ditto
cduvall 2012/08/09 19:20:08 Done.
+ result = self._Query(key, namespace)
+ if result is None:
+ return None
+ return result.value
+
+ def Delete(self, key, namespace):
+ result = self._Query(key, namespace)
+ if result is None:
+ return None
+ result.delete()

Powered by Google App Engine
This is Rietveld 408576698