def isMobileRequest(self, site, request, mobileDomainPrefixes, mobileDomainSuffixes, mobileViaIP): """ Determine should this request be rendered in mobile mode. @return: True or False """ # # Special HTTP GET query parameter telling # that render this as a preview request # if request.get("view_mode") == "mobile": # IFRAME request return True # # Determine if this is targeted to mobile domain # based on request domain name # host = get_host(request) if host: host = host.lower() # print "Got host:" + str(host) host = host.split(":")[0] # Remove port # Special rule to use mobiles for LAN/WLAN traffic if mobileViaIP and is_numeric_ipv4(host): return True # Go through each subdomain name and compare it to mobile markers for part in host.split(".")[0:-1]: for prefix in mobileDomainPrefixes: #print "Comparing " + prefix + " " + part if part == prefix: return True for suffix in mobileDomainSuffixes: if host.endswith("." + suffix): return True return False
def get_google_map_api_key_for_current_domain(self): """ Some magic to fetch domain specific Maps API key. You need API key as google_map_api_key_en or google_map_api_key_mobipublic_com """ host = get_host(self.request) domain = host.split(":")[0] domain = domain.replace(".","_") property_name = "google_map_api_key_" + domain print "Map key property:" + property_name key = self.get_property(property_name) print "Got key:" + str(key) return key