[CalendarServer-changes] [12471] twext/trunk/twext/who

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 11:17:39 PDT 2014


Revision: 12471
          http://trac.calendarserver.org//changeset/12471
Author:   wsanchez at apple.com
Date:     2014-01-29 18:27:24 -0800 (Wed, 29 Jan 2014)
Log Message:
-----------
Minor clean up of XML service.

Modified Paths:
--------------
    twext/trunk/twext/who/test/test_aggregate.py
    twext/trunk/twext/who/xml.py

Modified: twext/trunk/twext/who/test/test_aggregate.py
===================================================================
--- twext/trunk/twext/who/test/test_aggregate.py	2014-01-30 01:06:28 UTC (rev 12470)
+++ twext/trunk/twext/who/test/test_aggregate.py	2014-01-30 02:27:24 UTC (rev 12471)
@@ -24,12 +24,13 @@
 from ..idirectory import IDirectoryService, DirectoryConfigurationError
 from ..directory import DirectoryRecord
 from ..aggregate import DirectoryService
+from ..xml import RecordTypeValue
 from ..util import ConstantsContainer
 from . import test_directory, test_xml
 from .test_xml import (
     BaseTest as XMLBaseTest,
     QueryMixIn, xmlService, TestService as XMLTestService,
-    DirectoryServiceConvenienceTestMixIn
+    DirectoryServiceConvenienceTestMixIn,
 )
 
 

Modified: twext/trunk/twext/who/xml.py
===================================================================
--- twext/trunk/twext/who/xml.py	2014-01-30 01:06:28 UTC (rev 12470)
+++ twext/trunk/twext/who/xml.py	2014-01-30 02:27:24 UTC (rev 12471)
@@ -41,7 +41,7 @@
 from .idirectory import (
     DirectoryServiceError,
     NoSuchRecordError, UnknownRecordTypeError,
-    RecordType, FieldName as BaseFieldName,
+    RecordType as BaseRecordType, FieldName as BaseFieldName,
 )
 from .index import (
     DirectoryService as BaseDirectoryService,
@@ -103,21 +103,15 @@
 
 
 
-class Value(Values):
+class RecordTypeValue(Values):
     #
-    # Booleans
-    #
-    true  = ValueConstant(u"true")
-    false = ValueConstant(u"false")
-
-    #
     # Record types
     #
     user = ValueConstant(u"user")
-    user.recordType = RecordType.user
+    user.recordType = BaseRecordType.user
 
     group = ValueConstant(u"group")
-    group.recordType = RecordType.group
+    group.recordType = BaseRecordType.group
 
 
 
@@ -130,11 +124,14 @@
     XML directory service.
     """
 
-    recordType = ConstantsContainer((RecordType.user, RecordType.group))
+    recordType = ConstantsContainer(
+        (BaseRecordType.user, BaseRecordType.group)
+    )
 
-    element   = Element
-    attribute = Attribute
-    value     = Value
+    # XML schema constants
+    element         = Element
+    attribute       = Attribute
+    recordTypeValue = RecordTypeValue
 
     refreshInterval = 4
 
@@ -287,7 +284,9 @@
         if recordTypeAttribute:
             try:
                 recordType = (
-                    self.value.lookupByValue(recordTypeAttribute).recordType
+                    self.recordTypeValue
+                    .lookupByValue(recordTypeAttribute)
+                    .recordType
                 )
             except (ValueError, AttributeError):
                 raise UnknownRecordTypeError(recordTypeAttribute)
@@ -354,10 +353,8 @@
 
         # Index the record type -> attribute mappings.
         recordTypes = {}
-        for valueName in self.value.iterconstants():
-            recordType = getattr(valueName, "recordType", None)
-            if recordType is not None:
-                recordTypes[recordType] = valueName.value
+        for valueName in self.recordTypeValue.iterconstants():
+            recordTypes[valueName.recordType] = valueName.value
         del valueName
 
         # Index the field name -> element mappings.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/d476d0e9/attachment.html>


More information about the calendarserver-changes mailing list