annotate rhodecode/lib/rcmail/utils.py @ 3134:ff315659d289 beta

logging: make 'Creating a cache key for...' more readable
author Mads Kiilerich <madski@unity3d.com>
date Wed, 02 Jan 2013 13:54:24 +0100
parents d5e42c00f3c1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2495
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 """
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 Email message and email sending related helper functions.
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 """
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5 import socket
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 # Cache the hostname, but do it lazily: socket.getfqdn() can take a couple of
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 # seconds, which slows down the restart of the server.
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 class CachedDnsName(object):
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 def __str__(self):
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 return self.get_fqdn()
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 def get_fqdn(self):
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 if not hasattr(self, '_fqdn'):
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 self._fqdn = socket.getfqdn()
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 return self._fqdn
9766f0baf5c5 Use local_hostname in mailer
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18
2673
d5e42c00f3c1 white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2495
diff changeset
19 DNS_NAME = CachedDnsName()