[CalendarServer-changes] [7358] CalendarServer/branches/users/cdaboo/pods/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Mon Apr 25 18:23:34 PDT 2011


Revision: 7358
          http://trac.macosforge.org/projects/calendarserver/changeset/7358
Author:   cdaboo at apple.com
Date:     2011-04-25 18:23:34 -0700 (Mon, 25 Apr 2011)
Log Message:
-----------
Fix OD-based resource service.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/appleopendirectory.py
    CalendarServer/branches/users/cdaboo/pods/twistedcaldav/stdconfig.py

Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/appleopendirectory.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/appleopendirectory.py	2011-04-22 19:41:03 UTC (rev 7357)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/appleopendirectory.py	2011-04-26 01:23:34 UTC (rev 7358)
@@ -325,6 +325,8 @@
             'appliesTo' : set([
                 dsattributes.kDSStdRecordTypeUsers,
                 dsattributes.kDSStdRecordTypeGroups,
+                dsattributes.kDSStdRecordTypeResources,
+                dsattributes.kDSStdRecordTypePlaces,
             ]),
         },
         'firstName' : {
@@ -351,6 +353,8 @@
             'appliesTo' : set([
                 dsattributes.kDSStdRecordTypeUsers,
                 dsattributes.kDSStdRecordTypeGroups,
+                dsattributes.kDSStdRecordTypeResources,
+                dsattributes.kDSStdRecordTypePlaces,
             ]),
         },
         'guid' : {
@@ -358,6 +362,8 @@
             'appliesTo' : set([
                 dsattributes.kDSStdRecordTypeUsers,
                 dsattributes.kDSStdRecordTypeGroups,
+                dsattributes.kDSStdRecordTypeResources,
+                dsattributes.kDSStdRecordTypePlaces,
             ]),
         },
     }
@@ -367,6 +373,10 @@
             dsattributes.kDSStdRecordTypeUsers,
         DirectoryService.recordType_groups :
             dsattributes.kDSStdRecordTypeGroups,
+        DirectoryService.recordType_resources :
+            dsattributes.kDSStdRecordTypeResources,
+        DirectoryService.recordType_locations :
+            dsattributes.kDSStdRecordTypePlaces,
     }
 
     _fromODRecordTypes = dict([(b, a) for a, b in _toODRecordTypes.iteritems()])
@@ -604,8 +614,17 @@
             ]
 
             if recordType == DirectoryService.recordType_users:
-                listRecordTypes = [dsattributes.kDSStdRecordTypeUsers]
+                listRecordTypes = [self._toODRecordTypes[recordType]]
 
+            if recordType in (
+                DirectoryService.recordType_resources,
+                DirectoryService.recordType_locations,
+            ):
+                if queryattr == dsattributes.kDSNAttrEMailAddress:
+                    continue
+
+                listRecordTypes = [self._toODRecordTypes[recordType]]
+
             elif recordType == DirectoryService.recordType_groups:
 
                 if queryattr == dsattributes.kDSNAttrEMailAddress:

Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/stdconfig.py	2011-04-22 19:41:03 UTC (rev 7357)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/stdconfig.py	2011-04-26 01:23:34 UTC (rev 7358)
@@ -121,6 +121,14 @@
         "xmlFile": "resources.xml",
         "recordTypes" : ("locations", "resources"),
     },
+    "twistedcaldav.directory.appleopendirectory.OpenDirectoryService": {
+        "node": "/Search",
+        "cacheTimeout": 1,
+        "negativeCaching": False,
+        "restrictEnabledRecords": False,
+        "restrictToGroup": "",
+        "recordTypes" : ("locations", "resources"),
+    },
 }
 
 DEFAULT_AUGMENT_PARAMS = {
@@ -889,7 +897,33 @@
             if param not in DEFAULT_SERVICE_PARAMS[configDict.DirectoryService.type]:
                 del configDict.DirectoryService.params[param]
 
+def _preUpdateResourceService(configDict, items):
+    # Special handling for directory services configs
+    dsType = items.get("ResourceService", {}).get("type", None)
+    if dsType is None:
+        dsType = configDict.ResourceService.type
+    else:
+        if dsType == configDict.ResourceService.type:
+            oldParams = configDict.ResourceService.params
+            newParams = items.ResourceService.get("params", {})
+            _mergeData(oldParams, newParams)
+        else:
+            if dsType in DEFAULT_RESOURCE_PARAMS:
+                configDict.ResourceService.params = copy.deepcopy(DEFAULT_RESOURCE_PARAMS[dsType])
+            else:
+                configDict.ResourceService.params = {}
 
+    for param in items.get("ResourceService", {}).get("params", {}):
+        if dsType in DEFAULT_RESOURCE_PARAMS and param not in DEFAULT_RESOURCE_PARAMS[dsType]:
+            log.warn("Parameter %s is not supported by service %s" % (param, dsType))
+            
+def _postUpdateResourceService(configDict):
+    if configDict.ResourceService.type in DEFAULT_RESOURCE_PARAMS:
+        for param in tuple(configDict.ResourceService.params):
+            if param not in DEFAULT_RESOURCE_PARAMS[configDict.ResourceService.type]:
+                del configDict.ResourceService.params[param]
+
+
 def _preUpdateDirectoryAddressBookBackingDirectoryService(configDict, items):
     #
     # Special handling for directory address book configs
@@ -1166,12 +1200,14 @@
 
 PRE_UPDATE_HOOKS = (
     _preUpdateDirectoryService,
+    _preUpdateResourceService,
     _preUpdateDirectoryAddressBookBackingDirectoryService,
     )
 POST_UPDATE_HOOKS = (
     _updateDataStore,
     _updateHostName,
     _postUpdateDirectoryService,
+    _postUpdateResourceService,
     _postUpdateAugmentService,
     _postUpdateProxyDBService,
     _updateACLs,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110425/866b7180/attachment.html>


More information about the calendarserver-changes mailing list