3 # Copyright 2007 Google Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
21 """Stub version of the blob-related parts of the images API."""
31 from google
.appengine
.api
import datastore
37 BLOB_SERVING_URL_KIND
= "__BlobServingUrl__"
40 class ImagesBlobStub(object):
41 """Stub version of the blob-related parts of the images API."""
43 def __init__(self
, host_prefix
):
44 """Stub implementation of blob-related parts of the images API.
47 host_prefix: the URL prefix (protocol://host:port) to preprend to
48 image urls on a call to GetUrlBase.
50 self
._host
_prefix
= host_prefix
52 def GetUrlBase(self
, request
, response
):
53 """Trivial implementation of ImagesService::GetUrlBase.
56 request: ImagesGetUrlBaseRequest, contains a blobkey to an image
57 response: ImagesGetUrlBaseResponse, contains a url to serve the image
59 if request
.create_secure_url():
60 logging
.info("Secure URLs will not be created using the development "
61 "application server.")
63 entity_info
= datastore
.Entity(BLOB_SERVING_URL_KIND
,
64 name
=request
.blob_key(),
66 entity_info
["blob_key"] = request
.blob_key()
67 datastore
.Put(entity_info
)
69 response
.set_url("%s/_ah/img/%s" % (self
._host
_prefix
, request
.blob_key()))
71 def DeleteUrlBase(self
, request
, response
):
72 """Trivial implementation of ImagesService::DeleteUrlBase.
75 request: ImagesDeleteUrlBaseRequest, contains a blobkey to an image.
76 response: ImagesDeleteUrlBaseResonse - currently unused.
78 key
= datastore
.Key
.from_path(BLOB_SERVING_URL_KIND
,