def _Dynamic_AllocateIds(self, request, response):

    if request.reserve_size() > 0:
      app_id = request.reserve(0).partition_id().dataset_id()
    elif request.allocate_size() > 0:
      app_id = request.allocate(0).partition_id().dataset_id()
    else:
      app_id = None

    if app_id == self.target_app_id:
      self._MakeRemoteSyncCall(self.ServiceName(), 'AllocateIds', request,
                               response)
    else:
      self.normal_stub.MakeSyncCall(self.ServiceName(), 'AllocateIds', request,
                                    response)
Handle v4 AllocateIds and route remotely if it matches the target app.
dataset/ETHPy150Open GoogleCloudPlatform/python-compat-runtime/appengine-compat/exported_appengine_sdk/google/appengine/ext/datastore_admin/remote_api_put_stub.py/RemoteApiDatastoreV4Stub._Dynamic_AllocateIds