thirdparty/google_appengine/google/appengine/api/user_service_stub.py
changeset 686 df109be0567c
parent 109 620f9b141567
child 2864 2e0b0af889be
equal deleted inserted replaced
685:a440ced9a75f 686:df109be0567c
    19 
    19 
    20 
    20 
    21 import os
    21 import os
    22 import urllib
    22 import urllib
    23 import urlparse
    23 import urlparse
       
    24 from google.appengine.api import apiproxy_stub
    24 from google.appengine.api import user_service_pb
    25 from google.appengine.api import user_service_pb
    25 
    26 
    26 
    27 
    27 _DEFAULT_LOGIN_URL = 'https://www.google.com/accounts/Login?continue=%s'
    28 _DEFAULT_LOGIN_URL = 'https://www.google.com/accounts/Login?continue=%s'
    28 _DEFAULT_LOGOUT_URL = 'https://www.google.com/accounts/Logout?continue=%s'
    29 _DEFAULT_LOGOUT_URL = 'https://www.google.com/accounts/Logout?continue=%s'
    29 
    30 
    30 
    31 
    31 class UserServiceStub(object):
    32 class UserServiceStub(apiproxy_stub.APIProxyStub):
    32   """Trivial implementation of the UserService."""
    33   """Trivial implementation of the UserService."""
    33 
    34 
    34   def __init__(self,
    35   def __init__(self,
    35                login_url=_DEFAULT_LOGIN_URL,
    36                login_url=_DEFAULT_LOGIN_URL,
    36                logout_url=_DEFAULT_LOGOUT_URL):
    37                logout_url=_DEFAULT_LOGOUT_URL,
       
    38                service_name='user'):
    37     """Initializer.
    39     """Initializer.
    38 
    40 
    39     Args:
    41     Args:
    40       login_url: String containing the URL to use for logging in.
    42       login_url: String containing the URL to use for logging in.
    41       logout_url: String containing the URL to use for logging out.
    43       logout_url: String containing the URL to use for logging out.
       
    44       service_name: Service name expected for all calls.
    42 
    45 
    43     Note: Both the login_url and logout_url arguments must contain one format
    46     Note: Both the login_url and logout_url arguments must contain one format
    44     parameter, which will be replaced with the continuation URL where the user
    47     parameter, which will be replaced with the continuation URL where the user
    45     should be redirected after log-in or log-out has been completed.
    48     should be redirected after log-in or log-out has been completed.
    46     """
    49     """
       
    50     super(UserServiceStub, self).__init__(service_name)
    47     self.__num_requests = 0
    51     self.__num_requests = 0
    48     self._login_url = login_url
    52     self._login_url = login_url
    49     self._logout_url = logout_url
    53     self._logout_url = logout_url
    50 
    54 
    51     os.environ['AUTH_DOMAIN'] = 'gmail.com'
    55     os.environ['AUTH_DOMAIN'] = 'gmail.com'
    52 
    56 
    53   def num_requests(self):
    57   def num_requests(self):
    54     return self.__num_requests
    58     return self.__num_requests
    55 
       
    56   def MakeSyncCall(self, service, call, request, response):
       
    57     """The apiproxy entry point.
       
    58 
       
    59     Args:
       
    60       service: must be 'user'
       
    61       call: string representing which function to call
       
    62       request: the URL to redirect to, a base.StringProto
       
    63       response: the URL, a base.StringProto
       
    64 
       
    65     Currently, CreateLoginURL and CreateLogoutURL are supported.
       
    66     """
       
    67     assert service == 'user'
       
    68 
       
    69     method = getattr(self, "_Dynamic_" + call)
       
    70     method(request, response)
       
    71 
    59 
    72   def _Dynamic_CreateLoginURL(self, request, response):
    60   def _Dynamic_CreateLoginURL(self, request, response):
    73     """Trivial implementation of UserService.CreateLoginURL().
    61     """Trivial implementation of UserService.CreateLoginURL().
    74 
    62 
    75     Args:
    63     Args: