| author | ymh <ymh.work@gmail.com> |
| Tue, 25 May 2010 02:43:45 +0200 | |
| changeset 29 | cc9b7e14412b |
| permissions | -rw-r--r-- |
| 29 | 1 |
""" |
2 |
Email message and email sending related helper functions. |
|
3 |
""" |
|
4 |
||
5 |
import socket |
|
6 |
||
7 |
||
8 |
# Cache the hostname, but do it lazily: socket.getfqdn() can take a couple of |
|
9 |
# seconds, which slows down the restart of the server. |
|
10 |
class CachedDnsName(object): |
|
11 |
def __str__(self): |
|
12 |
return self.get_fqdn() |
|
13 |
||
14 |
def get_fqdn(self): |
|
15 |
if not hasattr(self, '_fqdn'): |
|
16 |
self._fqdn = socket.getfqdn() |
|
17 |
return self._fqdn |
|
18 |
||
19 |
DNS_NAME = CachedDnsName() |