Adding the orphaned options pages to the navigation
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / blob_reference_store.py
blob7edf5ee0ba9b24751aa29ceabd905035e4a3ade8
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.
5 from appengine_wrappers import db
6 from appengine_wrappers import BlobReferenceProperty
8 BLOB_REFERENCE_BLOBSTORE = 'BlobReferenceBlobstore'
10 class _Model(db.Model):
11 key_ = db.StringProperty()
12 value = BlobReferenceProperty()
14 class BlobReferenceStore(object):
15 """A wrapper around the datastore API that can store blob keys.
16 """
17 def _Query(self, namespace, key):
18 return _Model.gql('WHERE key_ = :1', self._MakeKey(namespace, key)).get()
20 def _MakeKey(self, namespace, key):
21 return '.'.join((namespace, key))
23 def Set(self, namespace, key, value):
24 _Model(key_=self._MakeKey(namespace, key), value=value).put()
26 def Get(self, namespace, key):
27 result = self._Query(namespace, key)
28 if not result:
29 return None
30 return result.value
32 def Delete(self, namespace, key):
33 result = self._Query(namespace, key)
34 if not result:
35 return None
36 blob_key = result.value
37 result.delete()
38 return blob_key