def execute_query(request, design_id=None, query_history_id=None):
 action = 'query'
 if query_history_id:
  query_history = authorized_get_query_history(request, query_history_id, must_exist=True)
  design = query_history.design
  try:
   if (query_history.server_id and query_history.server_guid):
    (handle, state) = _get_query_handle_and_state(query_history)
   if ('on_success_url' in request.GET):
    if (request.GET.get('on_success_url') and any([regexp.match(request.GET.get('on_success_url')) for regexp in REDIRECT_WHITELIST.get()])):
     action = 'watch-redirect'
    else:
     action = 'watch-results'
   else:
    action = 'editor-results'
  except QueryServerException as e:
   if (('Invalid query handle' in e.message) or ('Invalid OperationHandle' in e.message)):
    query_history.save_state(QueryHistory.STATE.expired)
    LOG.warn('Invalid query handle', exc_info=sys.exc_info())
    action = 'editor-expired-results'
   else:
    raise e
 else:
  authorized_get_design(request, design_id)
  app_name = get_app_name(request)
  query_type = SavedQuery.TYPES_MAPPING[app_name]
  design = safe_get_design(request, query_type, design_id)
  query_history = None
 doc = (design and design.id and design.doc.get())
 context = {'design': design, 'query': query_history, 'query_history': query_history, 'autocomplete_base_url': reverse((get_app_name(request) + ':api_autocomplete_databases'), kwargs={}), 'autocomplete_base_url_hive': reverse('beeswax:api_autocomplete_databases', kwargs={}), 'can_edit_name': (design and design.id and (not design.is_auto)), 'doc_id': ((doc and doc.id) or (-1)), 'can_edit': (doc and doc.can_write(request.user)), 'action': action, 'on_success_url': request.GET.get('on_success_url'), 'has_metastore': ('metastore' in get_apps_dict(request.user))}
 return render('execute.mako', request, context)

def execute_query ( request , design_id = None , query_history_id = None ) : action = 'query' if query_history_id : query_history = authorized_get_query_history ( request , query_history_id , must_exist = True ) design = query_history . design try : if ( query_history . server_id and query_history . server_guid ) : ( handle , state ) = _get_query_handle_and_state ( query_history ) if ( 'on_success_url' in request . GET ) : if ( request . GET . get ( 'on_success_url' ) and any ( [ regexp . match ( request . GET . get ( 'on_success_url' ) ) for regexp in REDIRECT_WHITELIST . get ( ) ] ) ) : action = 'watch-redirect' else : action = 'watch-results' else : action = 'editor-results' except QueryServerException as e : if ( ( 'Invalid query handle' in e . message ) or ( 'Invalid OperationHandle' in e . message ) ) : query_history . save_state ( QueryHistory . STATE . expired ) LOG . warn ( 'Invalid query handle' , exc_info = sys . exc_info ( ) ) action = 'editor-expired-results' else : raise e else : authorized_get_design ( request , design_id ) app_name = get_app_name ( request ) query_type = SavedQuery . TYPES_MAPPING [ app_name ] design = safe_get_design ( request , query_type , design_id ) query_history = None doc = ( design and design . id and design . doc . get ( ) ) context = { 'design' : design , 'query' : query_history , 'query_history' : query_history , 'autocomplete_base_url' : reverse ( ( get_app_name ( request ) + ':api_autocomplete_databases' ) , kwargs = { } ) , 'autocomplete_base_url_hive' : reverse ( 'beeswax:api_autocomplete_databases' , kwargs = { } ) , 'can_edit_name' : ( design and design . id and ( not design . is_auto ) ) , 'doc_id' : ( ( doc and doc . id ) or ( - 1 ) ) , 'can_edit' : ( doc and doc . can_write ( request . user ) ) , 'action' : action , 'on_success_url' : request . GET . get ( 'on_success_url' ) , 'has_metastore' : ( 'metastore' in get_apps_dict ( request . user ) ) } return render ( 'execute.mako' , request , context )
view function for executing an arbitrary synchronously query .