comparison rhodecode/lib/rcmail/utils.py @ 2495:9766f0baf5c5 beta

Use local_hostname in mailer
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 20 Jun 2012 21:12:56 +0200
parents
children d5e42c00f3c1
comparison
equal deleted inserted replaced
2494:c4d418b440d1 2495:9766f0baf5c5
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()