Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.10/site-packages/django/core/mail/utils.py: 60%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

10 statements  

1""" 

2Email message and email sending related helper functions. 

3""" 

4 

5import socket 

6 

7from django.utils.encoding import punycode 

8 

9 

10# Cache the hostname, but do it lazily: socket.getfqdn() can take a couple of 

11# seconds, which slows down the restart of the server. 

12class CachedDnsName: 

13 def __str__(self): 

14 return self.get_fqdn() 

15 

16 def get_fqdn(self): 

17 if not hasattr(self, "_fqdn"): 

18 self._fqdn = punycode(socket.getfqdn()) 

19 return self._fqdn 

20 

21 

22DNS_NAME = CachedDnsName()