[CalendarServer-changes] [12401] twext/trunk/twext/who/ldap/_service.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:22:29 PDT 2014
Revision: 12401
http://trac.calendarserver.org//changeset/12401
Author: wsanchez at apple.com
Date: 2014-01-20 12:42:04 -0800 (Mon, 20 Jan 2014)
Log Message:
-----------
Error handling.
Modified Paths:
--------------
twext/trunk/twext/who/ldap/_service.py
Modified: twext/trunk/twext/who/ldap/_service.py
===================================================================
--- twext/trunk/twext/who/ldap/_service.py 2014-01-20 20:28:04 UTC (rev 12400)
+++ twext/trunk/twext/who/ldap/_service.py 2014-01-20 20:42:04 UTC (rev 12401)
@@ -89,7 +89,12 @@
"""
+class LDAPQueryError(LDAPError):
+ """
+ LDAP query error.
+ """
+
#
# LDAP schema descriptions
#
@@ -273,7 +278,7 @@
@raises: L{LDAPConnectionError} if unable to connect.
"""
if not hasattr(self, "_connection"):
- self.log.info("Connecting to LDAP at {source.url}")
+ self.log.info("Connecting to LDAP at {log_source.url}")
connection = ldap.initialize(self.url)
# FIXME: Use trace_file option to wire up debug logging when
@@ -289,7 +294,7 @@
connection.set_option(option, value)
if self._useTLS:
- self.log.info("Starting TLS for {source.url}")
+ self.log.info("Starting TLS for {log_source.url}")
yield deferToThread(connection.start_tls_s)
if self._credentials is not None:
@@ -332,9 +337,16 @@
self.log.debug("Performing LDAP query: {query}", query=queryString)
- reply = connection.search_s(
- self._baseDN, ldap.SCOPE_SUBTREE, queryString # FIXME: attrs
- )
+ try:
+ reply = connection.search_s(
+ self._baseDN, ldap.SCOPE_SUBTREE, queryString # FIXME: attrs
+ )
+ except ldap.FILTER_ERROR as e:
+ self.log.error(
+ "Unable to perform query {0!r}: {1}"
+ .format(queryString, e)
+ )
+ raise LDAPQueryError("Unable to perform query", e)
records = []
@@ -358,7 +370,7 @@
except KeyError:
self.log.debug(
"Ignoring LDAP record data; no UID attribute "
- "({source._uidField}): {recordData!r}",
+ "({log_source._uidField}): {recordData!r}",
recordData=recordData
)
continue
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/e15d15e0/attachment.html>
More information about the calendarserver-changes
mailing list