app/soc/views/helper/requests.py
changeset 2871 e440e94a874b
parent 2867 e8d86272e6ea
child 2879 cb0f9b4646aa
equal deleted inserted replaced
2869:1ac6a1e1e429 2871:e440e94a874b
    20 __authors__ = [
    20 __authors__ = [
    21   '"Todd Larsen" <tlarsen@google.com>',
    21   '"Todd Larsen" <tlarsen@google.com>',
    22   ]
    22   ]
    23 
    23 
    24 
    24 
       
    25 import os
    25 import urlparse
    26 import urlparse
    26 
       
    27 from soc.logic import system
       
    28 
    27 
    29 
    28 
    30 def getSingleIndexedParamValue(request, param_name, values=()):
    29 def getSingleIndexedParamValue(request, param_name, values=()):
    31   """Returns a value indexed by a query parameter in the HTTP request.
    30   """Returns a value indexed by a query parameter in the HTTP request.
    32   
    31   
   118 
   117 
   119   if not http_from:
   118   if not http_from:
   120     # no HTTP referrer, so cannot possibly start with expected prefix
   119     # no HTTP referrer, so cannot possibly start with expected prefix
   121     return False
   120     return False
   122 
   121 
   123   http_host = 'http://%s/%s' % (system.getHostname(), url_name)
   122   http_host = 'http://%s/%s' % (os.environ['HTTP_HOST'], url_name)
   124 
   123 
   125   if http_from.startswith(http_host):
   124   if http_from.startswith(http_host):
   126     return True
   125     return True
   127 
   126 
   128   from_path = urlparse.urlparse(http_from).path
   127   from_path = urlparse.urlparse(http_from).path