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

Side by Side 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 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 BLOB_REFERENCE_BLOBSTORE = 'BlobReferenceBlobstore'
9
10 class _Model(db.Model):
11 key_ = db.StringProperty()
12 value = BlobReferenceProperty()
13
14 class BlobReferenceStore(object):
15 """A wrapper around the datastore API that can store blob keys.
16 """
17 def __init__(self, branch):
18 self._branch = branch
19
20 def _Query(self, namespace, key):
21 return _Model.gql('WHERE key_ = :1', self._MakeKey(namespace, key)).get()
22
23 def _MakeKey(self, namespace, key):
24 return '.'.join([self._branch, namespace, key])
25
26 def Set(self, namespace, key, value):
27 _Model(key_=self._MakeKey(namespace, key), value=value).put()
28
29 def Get(self, namespace, key):
30 result = self._Query(namespace, key)
31 if not result:
32 return None
33 return result.value
34
35 def Delete(self, namespace, key):
36 result = self._Query(namespace, key)
37 if not result:
38 return None
39 blob_key = result.value
40 result.delete()
41 return blob_key
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698