MCPcopy
hub / github.com/django/django / _get_site_by_request

Method _get_site_by_request

django/contrib/sites/models.py:34–46  ·  view source on GitHub ↗
(self, request)

Source from the content-addressed store, hash-verified

32 return SITE_CACHE[site_id]
33
34 def _get_site_by_request(self, request):
35 host = request.get_host()
36 try:
37 # First attempt to look up the site by host with or without port.
38 if host not in SITE_CACHE:
39 SITE_CACHE[host] = self.get(domain__iexact=host)
40 return SITE_CACHE[host]
41 except Site.DoesNotExist:
42 # Fallback to looking up site after stripping port from the host.
43 domain, port = split_domain_port(host)
44 if domain not in SITE_CACHE:
45 SITE_CACHE[domain] = self.get(domain__iexact=domain)
46 return SITE_CACHE[domain]
47
48 def get_current(self, request=None):
49 """

Callers 1

get_currentMethod · 0.95

Calls 3

split_domain_portFunction · 0.90
get_hostMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected