Mercurial > kallithea
annotate rhodecode/lib/rcmail/utils.py @ 2913:bfffaa9aff58 beta
#589 search urlgenerator didn't properly escape special chars on url
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 09 Oct 2012 19:39:26 +0200 |
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() |