original_docstring: Select region and redirect to referring page
docstring: Select region and redirect to referring page
docstring_tokens: Select region and redirect to referring page
code: def select_region(self):
          """Select region and redirect to referring page"""
          return_to = self.request.params.get('returnto')
          return_to_path = return_to
          landingpage_route_paths = [self.request.route_path(name) for name in LANDINGPAGE_ROUTE_NAMES]
          if return_to_path not in landingpage_route_paths:
              return_to = self.request.route_path('dashboard')
          region = self.request.params.get('region')
          # NOTE: We normally don't want a GET request to modify data,
          #       but we're only updating the selected region in the session here.
          session = self.request.session
          session['region'] = region
          try:
              conn = self.get_connection(conn_type='vpc')
              if conn is None:
                  # Handle broken connection case (e.g. configured AWS GovCloud region without proper access)
                  forget(self.request)
                  self.request.session.delete()
                  return HTTPFound(location=self.request.route_path('login'))
              session['supported_platforms'] = self.get_account_attributes(['supported-platforms'])
              session['default_vpc'] = self.get_account_attributes(['default-vpc'])
              vpcs = conn.get_all_vpcs()
              if not vpcs or len(vpcs) == 0:
                  # remove vpc from supported-platforms
                  if 'VPC' in session.get('supported_platforms', []):
                      session.get('supported_platforms').remove('VPC')
          except BotoServerError as err:
              logging.error(err, "Could not properly verify VPC capabilities")
          return HTTPFound(location=return_to)
code_tokens: def select_region ( self ) : return_to = self . request . params . get ( 'returnto' ) return_to_path = return_to landingpage_route_paths = [ self . request . route_path ( name ) for name in LANDINGPAGE_ROUTE_NAMES ] if return_to_path not in landingpage_route_paths : return_to = self . request . route_path ( 'dashboard' ) region = self . request . params . get ( 'region' ) session = self . request . session session [ 'region' ] = region try : conn = self . get_connection ( conn_type = 'vpc' ) if conn is None : forget ( self . request ) self . request . session . delete ( ) return HTTPFound ( location = self . request . route_path ( 'login' ) ) session [ 'supported_platforms' ] = self . get_account_attributes ( [ 'supported-platforms' ] ) session [ 'default_vpc' ] = self . get_account_attributes ( [ 'default-vpc' ] ) vpcs = conn . get_all_vpcs ( ) if not vpcs or len ( vpcs ) == 0 : if 'VPC' in session . get ( 'supported_platforms' , [ ] ) : session . get ( 'supported_platforms' ) . remove ( 'VPC' ) except BotoServerError as err : logging . error ( err , "Could not properly verify VPC capabilities" ) return HTTPFound ( location = return_to )
short_docstring: Select region and redirect to referring page
short_docstring_tokens: Select region and redirect to referring page
comment: """Select region and redirect to referring page"""$SEP$# NOTE: We normally don't want a GET request to modify data,$SEP$#       but we're only updating the selected region in the session here.$SEP$# Handle broken connection case (e.g. configured AWS GovCloud region without proper access)$SEP$# remove vpc from supported-platforms