thirdparty/google_appengine/google/appengine/api/images/images_stub.py
changeset 686 df109be0567c
parent 109 620f9b141567
child 1278 a7766286a7be
equal deleted inserted replaced
685:a440ced9a75f 686:df109be0567c
    24 
    24 
    25 import PIL
    25 import PIL
    26 from PIL import _imaging
    26 from PIL import _imaging
    27 from PIL import Image
    27 from PIL import Image
    28 
    28 
       
    29 from google.appengine.api import apiproxy_stub
    29 from google.appengine.api import images
    30 from google.appengine.api import images
    30 from google.appengine.api.images import images_service_pb
    31 from google.appengine.api.images import images_service_pb
    31 from google.appengine.runtime import apiproxy_errors
    32 from google.appengine.runtime import apiproxy_errors
    32 
    33 
    33 
    34 
    34 class ImagesServiceStub(object):
    35 class ImagesServiceStub(apiproxy_stub.APIProxyStub):
    35   """Stub version of images API to be used with the dev_appserver."""
    36   """Stub version of images API to be used with the dev_appserver."""
    36 
    37 
    37   def __init__(self):
    38   def __init__(self, service_name='images'):
    38     """Preloads PIL to load all modules in the unhardened environment."""
    39     """Preloads PIL to load all modules in the unhardened environment.
       
    40 
       
    41     Args:
       
    42       service_name: Service name expected for all calls.
       
    43     """
       
    44     super(ImagesServiceStub, self).__init__(service_name)
    39     Image.init()
    45     Image.init()
    40 
       
    41   def MakeSyncCall(self, service, call, request, response):
       
    42     """Main entry point.
       
    43 
       
    44     Args:
       
    45       service: str, must be 'images'.
       
    46       call: str, name of the RPC to make, must be part of ImagesService.
       
    47       request: pb object, corresponding args to the 'call' argument.
       
    48       response: pb object, return value for the 'call' argument.
       
    49     """
       
    50     assert service == "images"
       
    51     assert request.IsInitialized()
       
    52 
       
    53     attr = getattr(self, "_Dynamic_" + call)
       
    54     attr(request, response)
       
    55 
    46 
    56   def _Dynamic_Transform(self, request, response):
    47   def _Dynamic_Transform(self, request, response):
    57     """Trivial implementation of ImagesService::Transform.
    48     """Trivial implementation of ImagesService::Transform.
    58 
    49 
    59     Based off documentation of the PIL library at
    50     Based off documentation of the PIL library at