summaryrefslogtreecommitdiff
path: root/src/leap/mx/alias_resolver.py
diff options
context:
space:
mode:
authorTomas Touceda <chiiph@leap.se>2013-05-02 13:44:08 -0300
committerTomas Touceda <chiiph@leap.se>2013-05-02 13:44:08 -0300
commitf844d2de4ce4582737ce02a0c9c5e0b2ff4dd026 (patch)
treebb7ed84a1c58eedade652ad66f3f4e6bf2cc659c /src/leap/mx/alias_resolver.py
parentc1eec313e873c9e2567db6798ef07f58953145da (diff)
Several fixes according to the review comments
Diffstat (limited to 'src/leap/mx/alias_resolver.py')
-rw-r--r--src/leap/mx/alias_resolver.py28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/leap/mx/alias_resolver.py b/src/leap/mx/alias_resolver.py
index 3f93f0d..68c6212 100644
--- a/src/leap/mx/alias_resolver.py
+++ b/src/leap/mx/alias_resolver.py
@@ -24,18 +24,15 @@ TODO:
controlling concurrent connections and throttling resource consumption.
"""
-import logging
-
try:
# TODO: we should probably use the system alias somehow
# from twisted.mail import alias
from twisted.protocols import postfix
+ from twisted.python import log
except ImportError:
print "This software requires Twisted. Please see the README file"
print "for instructions on getting required dependencies."
-logger = logging.getLogger(__name__)
-
class AliasResolverFactory(postfix.PostfixTCPMapDeferringDictServerFactory):
def __init__(self, couchdb, *args, **kwargs):
@@ -46,23 +43,24 @@ class AliasResolverFactory(postfix.PostfixTCPMapDeferringDictServerFactory):
if isinstance(result, unicode):
result = result.encode("utf8")
if result is None:
- logger.debug("Result not found")
+ log.msg("Result not found")
return result
def get(self, key):
- orig_key = key
try:
- logger.debug("Processing key: %s" % (key,))
+ log.msg("Processing key: %s" % (key,))
if key.find("@") == -1:
- logger.debug("Ignoring key since it's not an email address")
+ log.msg("Ignoring key since it's not an email address")
return None
key = key.split("@")[0]
key = key.split("+")[0]
- logger.debug("Final key to query: %s" % (key,))
- except Exception as e:
- key = orig_key
- logger.exception("%s" % (e,))
- d = self._cdb.queryByLoginOrAlias(key)
- d.addCallback(self._to_str)
- return d
+ log.msg("Final key to query: %s" % (key,))
+ d = self._cdb.queryByLoginOrAlias(key)
+ d.addCallback(self._to_str)
+ d.addErrback(log.err)
+ return d
+ except:
+ log.err()
+
+ return None