Source code for google.appengine.ext.ndb.google_imports

## Copyright 2008 The ndb Authors. All Rights Reserved.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License."""Dynamically decide from where to import Google App Engine modules.All other NDB code should import its Google App Engine modules fromthis module. If necessary, add new imports here (in both places)."""# pylint: disable=unused-import, g-import-not-at-topimportosimportsystry:importgoogleGOOGLE_PACKAGE_PATH=set(google.__path__)exceptImportError:GOOGLE_PACKAGE_PATH=None

try:fromgoogle.appengine.datastoreimportentity_pbnormal_environment=TrueexceptImportError:try:fromgoogle3.storage.onestore.v3importentity_pbnormal_environment=FalseexceptImportError:# If we are running locally but outside the context of App Engine.try:set_appengine_imports()fromgoogle.appengine.datastoreimportentity_pbnormal_environment=TrueexceptImportError:raiseImportError('Unable to find the App Engine SDK. ''Did you remember to set the "GAE" environment ''variable to be the path to the App Engine SDK?')ifnormal_environment:fromgoogle.appengine.api.blobstoreimportblobstoreasapi_blobstorefromgoogle.appengine.apiimportapiproxy_rpcfromgoogle.appengine.apiimportapiproxy_stub_mapfromgoogle.appengine.apiimportdatastorefromgoogle.appengine.apiimportdatastore_errorsfromgoogle.appengine.apiimportdatastore_typesfromgoogle.appengine.apiimportmemcachefromgoogle.appengine.apiimportnamespace_managerfromgoogle.appengine.apiimporttaskqueuefromgoogle.appengine.apiimporturlfetchfromgoogle.appengine.apiimportusersfromgoogle.appengine.datastoreimportdatastore_pbsfromgoogle.appengine.datastoreimportdatastore_queryfromgoogle.appengine.datastoreimportdatastore_rpc# This line will fail miserably for any app using auto_import_fixer# because auto_import_fixer only set up simple alias between# google and google3. But entity_pb is move to a different path completely.fromgoogle.appengine.datastoreimportentity_pbfromgoogle.appengine.ext.blobstoreimportblobstoreasext_blobstorefromgoogle.appengine.extimportdbfromgoogle.appengine.extimportgqltry:# For the python-compat runtime.fromgoogle.appengine.ext.vmruntimeimportcallbackexceptImportError:# For the python 2.7 runtime.try:fromgoogle.appengine.runtimeimportapiproxyascallback# Python 2.5 and dev_appserver is not supported.ifnothasattr(callback,'SetRequestEndCallback'):callback=NoneexceptImportError:callback=Nonefromgoogle.appengine.runtimeimportapiproxy_errorsfromgoogle.net.protoimportProtocolBufferelse:fromgoogle3.apphosting.api.blobstoreimportblobstoreasapi_blobstorefromgoogle3.apphosting.apiimportapiproxy_rpcfromgoogle3.apphosting.apiimportapiproxy_stub_mapfromgoogle3.apphosting.apiimportdatastorefromgoogle3.apphosting.apiimportdatastore_errorsfromgoogle3.apphosting.apiimportdatastore_typesfromgoogle3.apphosting.apiimportmemcachefromgoogle3.apphosting.apiimportnamespace_managerfromgoogle3.apphosting.apiimporttaskqueuefromgoogle3.apphosting.apiimporturlfetchfromgoogle3.apphosting.apiimportusersfromgoogle3.apphosting.datastoreimportdatastore_pbsfromgoogle3.apphosting.datastoreimportdatastore_queryfromgoogle3.apphosting.datastoreimportdatastore_rpcfromgoogle3.storage.onestore.v3importentity_pbfromgoogle3.apphosting.ext.blobstoreimportblobstoreasext_blobstorefromgoogle3.apphosting.extimportdbfromgoogle3.apphosting.extimportgqlfromgoogle3.apphosting.ext.vmruntimeimportcallbackfromgoogle3.apphosting.runtimeimportapiproxy_errorsfromgoogle3.net.protoimportProtocolBuffer