def init_blobstore_stub(self, enable=True): """Enable the blobstore stub. Args: enable: True, if the fake service should be enabled, False if real service should be disabled. """ if not enable: self._disable_stub(BLOBSTORE_SERVICE_NAME) return storage = dict_blob_storage.DictBlobStorage() stub = blobstore_stub.BlobstoreServiceStub(storage) self._register_stub(BLOBSTORE_SERVICE_NAME, stub)
def _Dynamic_SetBlobStorageType(self, request, unused_response, unused_request_id): """Configure whether stub should store blobs in-memory or on-disk. This is primarily used by the Java blobstore client APIs to switch between memory and file storage. Args: request: An instance of blobstore_stub_service_pb.SetBlobStorageTypeRequest. """ if request.storage_type() == ( blobstore_stub_service_pb.SetBlobStorageTypeRequest.MEMORY): self.__storage = dict_blob_storage.DictBlobStorage() elif request.storage_type() == ( blobstore_stub_service_pb.SetBlobStorageTypeRequest.FILE): self.__storage = file_blob_storage.FileBlobStorage( self._storage_dir, self._app_id)
def _get_blob_storage(self): """Creates a blob storage for stubs if needed.""" if self._blob_storage is None: self._blob_storage = dict_blob_storage.DictBlobStorage() return self._blob_storage
from google.appengine.api import taskqueue from google.appengine.api.taskqueue import taskqueue_stub from google.appengine.api import urlfetch_stub from ndb import * apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap() ds_stub = datastore_file_stub.DatastoreFileStub('_', None) apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', ds_stub) mc_stub = memcache_stub.MemcacheServiceStub() apiproxy_stub_map.apiproxy.RegisterStub('memcache', mc_stub) tq_stub = taskqueue_stub.TaskQueueServiceStub() apiproxy_stub_map.apiproxy.RegisterStub('taskqueue', tq_stub) uf_stub = urlfetch_stub.URLFetchServiceStub() apiproxy_stub_map.apiproxy.RegisterStub('urlfetch', uf_stub) bs_storage = dict_blob_storage.DictBlobStorage() bs_stub = blobstore_stub.BlobstoreServiceStub(bs_storage) apiproxy_stub_map.apiproxy.RegisterStub('blobstore', bs_stub) os.environ['APPLICATION_ID'] = '_' class Employee(Model): name = StringProperty() age = IntegerProperty() rank = IntegerProperty() @classmethod def demographic(cls, min_age, max_age): return cls.query().filter(AND(cls.age >= min_age, cls.age <= max_age)) @classmethod