[CalendarServer-changes] [10717] CalendarServer/trunk/twext/who
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 13 14:43:46 PST 2013
Revision: 10717
http://trac.calendarserver.org//changeset/10717
Author: wsanchez at apple.com
Date: 2013-02-13 14:43:46 -0800 (Wed, 13 Feb 2013)
Log Message:
-----------
Normalization is an attribute of the service, not the field.
Modified Paths:
--------------
CalendarServer/trunk/twext/who/directory.py
CalendarServer/trunk/twext/who/idirectory.py
Modified: CalendarServer/trunk/twext/who/directory.py
===================================================================
--- CalendarServer/trunk/twext/who/directory.py 2013-02-13 22:14:20 UTC (rev 10716)
+++ CalendarServer/trunk/twext/who/directory.py 2013-02-13 22:43:46 UTC (rev 10717)
@@ -23,6 +23,8 @@
"DirectoryRecord",
]
+from uuid import UUID
+
from zope.interface import implements
from twisted.python.util import FancyEqMixin
@@ -48,7 +50,12 @@
recordType = MergedConstants(RecordType)
fieldName = MergedConstants(FieldName)
+ fieldNormalizer = {
+ FieldName.guid: lambda g: UUID(g).hex,
+ FieldName.emailAddresses: lambda e: e.lower(),
+ }
+
def __init__(self, realmName):
self.realmName = realmName
@@ -167,7 +174,7 @@
# Normalize fields
normalizedFields = {}
for name, value in fields.items():
- normalize = getattr(name, "normalize", None)
+ normalize = service.fieldNormalizer.get(name, None)
if normalize is None:
normalizedFields[name] = value
Modified: CalendarServer/trunk/twext/who/idirectory.py
===================================================================
--- CalendarServer/trunk/twext/who/idirectory.py 2013-02-13 22:14:20 UTC (rev 10716)
+++ CalendarServer/trunk/twext/who/idirectory.py 2013-02-13 22:43:46 UTC (rev 10717)
@@ -37,8 +37,6 @@
"IDirectoryRecord",
]
-from uuid import UUID
-
from zope.interface import Attribute, Interface
from twisted.python.constants import Names, NamedConstant
@@ -126,11 +124,8 @@
def isMultiValue(name):
return getattr(name, "multiValue", False)
- guid.normalize = lambda g: UUID(g).hex
- emailAddresses.normalize = lambda e: e.lower()
-
class MatchType(Names):
"""
Query match types.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130213/ab79e081/attachment.html>
More information about the calendarserver-changes
mailing list