def Connect(driver_name=None, oauth2_refresh_token=None, **kwargs):
 driver = _GetDriver(driver_name)
 server_software = os.getenv('SERVER_SOFTWARE', '').split('/')[0]
 if ((server_software in (DEV_SERVER_SOFTWARE, PROD_SERVER_SOFTWARE)) and driver.__name__.endswith('rdbms_googleapi')):
  if (server_software == PROD_SERVER_SOFTWARE):
   logging.warning('Using the Google API driver is not recommended when running on production App Engine.  You should instead use the GAE API Proxy driver (google.storage.speckle.python.api.rdbms_apiproxy).')
  import oauth2client.client
  from google.storage.speckle.python.api import rdbms_googleapi
  from google.storage.speckle.python.django.backend import oauth2storage
  storage = kwargs.setdefault('oauth_storage', oauth2storage.storage)
  credentials = storage.get()
  if ((credentials is None) or credentials.invalid):
   if (not oauth2_refresh_token):
    oauth2_refresh_token = os.getenv('GOOGLE_SQL_OAUTH2_REFRESH_TOKEN')
   if (not oauth2_refresh_token):
    raise exceptions.ImproperlyConfigured('No valid OAuth 2.0 credentials.  Before using the Google SQL Service backend on dev_appserver, you must first run "manage.py syncdb" and proceed through the given instructions to fetch an OAuth 2.0 token.')
   credentials = oauth2client.client.OAuth2Credentials(None, rdbms_googleapi.CLIENT_ID, rdbms_googleapi.CLIENT_SECRET, oauth2_refresh_token, None, 'https://accounts.google.com/o/oauth2/token', rdbms_googleapi.USER_AGENT)
   credentials.set_store(storage)
   storage.put(credentials)
 return driver.connect(**kwargs)

def Connect ( driver_name = None , oauth2_refresh_token = None , ** kwargs ) : driver = _GetDriver ( driver_name ) server_software = os . getenv ( 'SERVER_SOFTWARE' , '' ) . split ( '/' ) [ 0 ] if ( ( server_software in ( DEV_SERVER_SOFTWARE , PROD_SERVER_SOFTWARE ) ) and driver . __name__ . endswith ( 'rdbms_googleapi' ) ) : if ( server_software == PROD_SERVER_SOFTWARE ) : logging . warning ( 'Using the Google API driver is not recommended when running on production App Engine.  You should instead use the GAE API Proxy driver (google.storage.speckle.python.api.rdbms_apiproxy).' ) import oauth2client . client from google . storage . speckle . python . api import rdbms_googleapi from google . storage . speckle . python . django . backend import oauth2storage storage = kwargs . setdefault ( 'oauth_storage' , oauth2storage . storage ) credentials = storage . get ( ) if ( ( credentials is None ) or credentials . invalid ) : if ( not oauth2_refresh_token ) : oauth2_refresh_token = os . getenv ( 'GOOGLE_SQL_OAUTH2_REFRESH_TOKEN' ) if ( not oauth2_refresh_token ) : raise exceptions . ImproperlyConfigured ( 'No valid OAuth 2.0 credentials.  Before using the Google SQL Service backend on dev_appserver, you must first run "manage.py syncdb" and proceed through the given instructions to fetch an OAuth 2.0 token.' ) credentials = oauth2client . client . OAuth2Credentials ( None , rdbms_googleapi . CLIENT_ID , rdbms_googleapi . CLIENT_SECRET , oauth2_refresh_token , None , 'https://accounts.google.com/o/oauth2/token' , rdbms_googleapi . USER_AGENT ) credentials . set_store ( storage ) storage . put ( credentials ) return driver . connect ( ** kwargs )
factory function for connections .