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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from appengine_wrappers import db
6 from appengine_wrappers import BlobReferenceProperty
7
8 DATASTORE_BLOBSTORE = 'DatastoreBlobstore'
9
10 class _Model(db.Model):
11 key_ = db.StringProperty()
12 value = BlobReferenceProperty()
13
14 class AppEngineDatastore(object):
15 """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.
16 """
17 def __init__(self, branch):
18 self._branch = branch
19
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.
20 def _Query(self, key, namespace):
21 result = _Model.gql('WHERE key_ = :1',
22 key + '.' + self._branch + '.' + namespace).get()
23 if not result:
24 return None
25 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.
26
27 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.
28 _Model(key_=key + '.' + self._branch + '.' + namespace, value=value).put()
29
30 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.
31 result = self._Query(key, namespace)
32 if result is None:
33 return None
34 return result.value
35
36 def Delete(self, key, namespace):
37 result = self._Query(key, namespace)
38 if result is None:
39 return None
40 result.delete()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698