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.
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
)
32 def Delete(self
, namespace
, key
):
33 result
= self
._Query
(namespace
, key
)
36 blob_key
= result
.value