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

Side by Side Diff: chrome/common/extensions/docs/server2/appengine_blobstore.py

Issue 15087006: Docserver: there is only one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: epic rebase Created 7 years, 5 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
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import blob_reference_store as datastore 5 import blob_reference_store as datastore
6 from blob_reference_store import BlobReferenceStore 6 from blob_reference_store import BlobReferenceStore
7 from appengine_wrappers import blobstore 7 from appengine_wrappers import blobstore
8 from appengine_wrappers import files 8 from appengine_wrappers import files
9 9
10 BLOBSTORE_GITHUB = 'BlobstoreGithub' 10 BLOBSTORE_GITHUB = 'BlobstoreGithub'
11 11
12 class AppEngineBlobstore(object): 12 class AppEngineBlobstore(object):
13 """A wrapper around the blobstore API, which stores the blob keys in 13 """A wrapper around the blobstore API, which stores the blob keys in
14 datastore. 14 datastore.
15 """ 15 """
16 def __init__(self): 16 def __init__(self):
17 self._datastore = BlobReferenceStore('blobstore') 17 self._datastore = BlobReferenceStore()
18 18
19 def Set(self, key, blob, namespace): 19 def Set(self, key, blob, namespace):
20 """Add a blob to the blobstore. |version| is used as part of the key so 20 """Add a blob to the blobstore. |version| is used as part of the key so
21 multiple blobs with the same name can be differentiated. 21 multiple blobs with the same name can be differentiated.
22 """ 22 """
23 key = namespace + '.' + key 23 key = namespace + '.' + key
24 filename = files.blobstore.create() 24 filename = files.blobstore.create()
25 with files.open(filename, 'a') as f: 25 with files.open(filename, 'a') as f:
26 f.write(blob) 26 f.write(blob)
27 files.finalize(filename) 27 files.finalize(filename)
(...skipping 11 matching lines...) Expand all
39 return blob_reader.read() 39 return blob_reader.read()
40 40
41 def Delete(self, key, namespace): 41 def Delete(self, key, namespace):
42 """Delete the blob with version |version| if it is found. 42 """Delete the blob with version |version| if it is found.
43 """ 43 """
44 key = namespace + '.' + key 44 key = namespace + '.' + key
45 blob_key = self._datastore.Delete(datastore.BLOB_REFERENCE_BLOBSTORE, key) 45 blob_key = self._datastore.Delete(datastore.BLOB_REFERENCE_BLOBSTORE, key)
46 if blob_key is None: 46 if blob_key is None:
47 return 47 return
48 blob_key.delete() 48 blob_key.delete()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698