Mercurial > kallithea
annotate rhodecode/lib/rcmail/utils.py @ 3608:87b0a652b6b1 beta
comments: "Comment on pull request" feels more natural
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Mon, 25 Mar 2013 16:30:40 +0100 |
parents | d5e42c00f3c1 |
children |
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() |