[CalendarServer-changes] [12865] CalendarServer/branches/users/sagen/move2who-2

source_changes at macosforge.org source_changes at macosforge.org
Mon Mar 10 11:19:32 PDT 2014


Revision: 12865
          http://trac.calendarserver.org//changeset/12865
Author:   sagen at apple.com
Date:     2014-03-10 11:19:32 -0700 (Mon, 10 Mar 2014)
Log Message:
-----------
Start moving older unit tests over to new directory API

Modified Paths:
--------------
    CalendarServer/branches/users/sagen/move2who-2/twistedcaldav/directory/test/accounts.xml
    CalendarServer/branches/users/sagen/move2who-2/twistedcaldav/test/util.py
    CalendarServer/branches/users/sagen/move2who-2/txdav/dps/server.py

Modified: CalendarServer/branches/users/sagen/move2who-2/twistedcaldav/directory/test/accounts.xml
===================================================================
--- CalendarServer/branches/users/sagen/move2who-2/twistedcaldav/directory/test/accounts.xml	2014-03-10 17:52:25 UTC (rev 12864)
+++ CalendarServer/branches/users/sagen/move2who-2/twistedcaldav/directory/test/accounts.xml	2014-03-10 18:19:32 UTC (rev 12865)
@@ -18,279 +18,261 @@
 
 <!DOCTYPE accounts SYSTEM "../../../conf/auth/accounts.dtd">
 
-<accounts realm="Test">
-  <user>
-    <uid>admin</uid>
-    <guid>D11F03A0-97EA-48AF-9A6C-FAC7F3975766</guid>
+<directory realm="Test">
+  <record type="user">
+    <short-name>admin</short-name>
+    <uid>D11F03A0-97EA-48AF-9A6C-FAC7F3975766</uid>
     <password>nimda</password>
-    <name>Administrators</name>
-  </user>
-  <user>
-    <uid>wsanchez</uid>
-    <guid>6423F94A-6B76-4A3A-815B-D52CFD77935D</guid>
+    <full-name>Administrators</full-name>
+  </record>
+  <record type="user">
+    <short-name>wsanchez</short-name>
+    <uid>6423F94A-6B76-4A3A-815B-D52CFD77935D</uid>
     <password>zehcnasw</password>
-    <name>Wilfredo Sanchez</name>
-    <email-address>wsanchez at example.com</email-address>
-  </user>
-  <user>
-    <uid>cdaboo</uid>
-    <guid>5A985493-EE2C-4665-94CF-4DFEA3A89500</guid>
+    <full-name>Wilfredo Sanchez</full-name>
+    <email>wsanchez at example.com</email>
+  </record>
+  <record type="user">
+    <short-name>cdaboo</short-name>
+    <uid>5A985493-EE2C-4665-94CF-4DFEA3A89500</uid>
     <password>oobadc</password>
-    <name>Cyrus Daboo</name>
-    <email-address>cdaboo at example.com</email-address>
-  </user>
-  <user>
-    <uid>lecroy</uid>
-    <guid>8B4288F6-CC82-491D-8EF9-642EF4F3E7D0</guid>
+    <full-name>Cyrus Daboo</full-name>
+    <email>cdaboo at example.com</email>
+  </record>
+  <record type="user">
+    <short-name>lecroy</short-name>
+    <uid>8B4288F6-CC82-491D-8EF9-642EF4F3E7D0</uid>
     <password>yorcel</password>
-    <name>Chris Lecroy</name>
-    <email-address>lecroy at example.com</email-address>
-  </user>
-  <user>
-    <uid>dreid</uid>
-    <guid>5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1</guid>
+    <full-name>Chris Lecroy</full-name>
+    <email>lecroy at example.com</email>
+  </record>
+  <record type="user">
+    <short-name>dreid</short-name>
+    <uid>5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1</uid>
     <password>dierd</password>
-    <name>David Reid</name>
-    <email-address>dreid at example.com</email-address>
-  </user>
-  <user>
-    <uid>doublequotes</uid>
-    <guid>8E04787E-336D-41ED-A70B-D233AD0DCE6F</guid>
+    <full-name>David Reid</full-name>
+    <email>dreid at example.com</email>
+  </record>
+  <record type="user">
+    <short-name>doublequotes</short-name>
+    <uid>8E04787E-336D-41ED-A70B-D233AD0DCE6F</uid>
     <password>setouqelbuod</password>
-    <name>Double "quotey" Quotes</name>
-    <email-address>doublequotes at example.com</email-address>
-  </user>
-  <user>
-    <uid>nocalendar</uid>
-    <guid>543D28BA-F74F-4D5F-9243-B3E3A61171E5</guid>
+    <full-name>Double "quotey" Quotes</full-name>
+    <email>doublequotes at example.com</email>
+  </record>
+  <record type="user">
+    <short-name>nocalendar</short-name>
+    <uid>543D28BA-F74F-4D5F-9243-B3E3A61171E5</uid>
     <password>radnelacon</password>
-    <name>No Calendar</name>
-    <email-address>nocalendar at example.com</email-address>
-  </user>
-  <user>
-    <uid>usera</uid>
-    <guid>7423F94A-6B76-4A3A-815B-D52CFD77935D</guid>
+    <full-name>No Calendar</full-name>
+    <email>nocalendar at example.com</email>
+  </record>
+  <record type="user">
+    <short-name>usera</short-name>
+    <uid>7423F94A-6B76-4A3A-815B-D52CFD77935D</uid>
     <password>a</password>
-    <name>a</name>
-    <email-address>a at example.com</email-address>
-  </user>
-  <user>
-    <uid>userb</uid>
-    <guid>8A985493-EE2C-4665-94CF-4DFEA3A89500</guid>
+    <full-name>a</full-name>
+    <email>a at example.com</email>
+  </record>
+  <record type="user">
+    <short-name>userb</short-name>
+    <uid>8A985493-EE2C-4665-94CF-4DFEA3A89500</uid>
     <password>b</password>
-    <name>b</name>
-    <email-address>b at example.com</email-address>
-  </user>
-  <user>
-    <uid>userc</uid>
-    <guid>9FF60DAD-0BDE-4508-8C77-15F0CA5C8DD2</guid>
+    <full-name>b</full-name>
+    <email>b at example.com</email>
+  </record>
+  <record type="user">
+    <short-name>userc</short-name>
+    <uid>9FF60DAD-0BDE-4508-8C77-15F0CA5C8DD2</uid>
     <password>c</password>
-    <name>c</name>
-    <email-address>c at example.com</email-address>
-  </user>
-  <user>
-    <uid>usercalonly</uid>
-    <guid>9E1FFAC4-3CCD-45A1-8272-D161C92D2EEE</guid>
+    <full-name>c</full-name>
+    <email>c at example.com</email>
+  </record>
+  <record type="user">
+    <short-name>usercalonly</short-name>
+    <uid>9E1FFAC4-3CCD-45A1-8272-D161C92D2EEE</uid>
     <password>a</password>
-    <name>a calonly</name>
-    <email-address>a-calonly at example.com</email-address>
-  </user>
-  <user>
-    <uid>useradbkonly</uid>
-    <guid>7678EC8A-A069-4E82-9066-7279C6718507</guid>
+    <full-name>a calonly</full-name>
+    <email>a-calonly at example.com</email>
+  </record>
+  <record type="user">
+    <short-name>useradbkonly</short-name>
+    <uid>7678EC8A-A069-4E82-9066-7279C6718507</uid>
     <password>a</password>
-    <name>a adbkonly</name>
-    <email-address>a-adbkonly at example.com</email-address>
-  </user>
-  <user>
-    <uid>nonascii</uid>
-    <uid>nonascii佐藤</uid>
-    <guid>320B73A1-46E2-4180-9563-782DFDBE1F63</guid>
+    <full-name>a adbkonly</full-name>
+    <email>a-adbkonly at example.com</email>
+  </record>
+  <record type="user">
+    <short-name>nonascii</short-name>
+    <short-name>nonascii佐藤</short-name>
+    <uid>320B73A1-46E2-4180-9563-782DFDBE1F63</uid>
     <password>a</password>
-    <name>佐藤佐藤佐藤</name>
-    <email-address>nonascii at example.com</email-address>
-  </user>
-  <user>
-    <uid>delegator</uid>
-    <guid>FC465590-E9E9-4746-ACE8-6C756A49FE4D</guid>
+    <full-name>佐藤佐藤佐藤</full-name>
+    <email>nonascii at example.com</email>
+  </record>
+  <record type="user">
+    <short-name>delegator</short-name>
+    <uid>FC465590-E9E9-4746-ACE8-6C756A49FE4D</uid>
     <password>a</password>
-    <name>Calendar Delegator</name>
-    <email-address>calendardelegator at example.com</email-address>
-  </user>
-  <user>
-    <uid>occasionaldelegate</uid>
-    <guid>EC465590-E9E9-4746-ACE8-6C756A49FE4D</guid>
+    <full-name>Calendar Delegator</full-name>
+    <email>calendardelegator at example.com</email>
+  </record>
+  <record type="user">
+    <short-name>occasionaldelegate</short-name>
+    <uid>EC465590-E9E9-4746-ACE8-6C756A49FE4D</uid>
     <password>a</password>
-    <name>Occasional Delegate</name>
-    <email-address>occasional at example.com</email-address>
-  </user>
-    <user>
-    <uid>delegateviagroup</uid>
-    <guid>46D9D716-CBEE-490F-907A-66FA6C3767FF</guid>
+    <full-name>Occasional Delegate</full-name>
+    <email>occasional at example.com</email>
+  </record>
+    <record type="user">
+    <short-name>delegateviagroup</short-name>
+    <uid>46D9D716-CBEE-490F-907A-66FA6C3767FF</uid>
     <password>a</password>
-    <name>Delegate Via Group</name>
-    <email-address>delegateviagroup at example.com</email-address>
-  </user>
-  <group>
-    <uid>delegategroup</uid>
-    <guid>00599DAF-3E75-42DD-9DB7-52617E79943F</guid>
-    <name>Delegate Group</name>
-    <members>
-      <member type="users">delegateviagroup</member>
-    </members>
-  </group>
+    <full-name>Delegate Via Group</full-name>
+    <email>delegateviagroup at example.com</email>
+  </record>
+  <record type="group">
+    <short-name>delegategroup</short-name>
+    <uid>00599DAF-3E75-42DD-9DB7-52617E79943F</uid>
+    <full-name>Delegate Group</full-name>
+      <member-uid>delegateviagroup</member-uid>
+  </record>
   <user repeat="100">
+    <short-name>user%02d</short-name>
     <uid>user%02d</uid>
-    <guid>user%02d</guid>
     <password>%02duser</password>
-    <name>~35 User %02d</name>
+    <full-name>~35 User %02d</full-name>
     <first-name>~5</first-name>
     <last-name>~9 User %02d</last-name>
-    <email-address>~10 at example.com</email-address>
+    <email>~10 at example.com</email>
   </user>
-  <group>
-    <uid>managers</uid>
-    <guid>9FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1</guid>
+  <record type="group">
+    <short-name>managers</short-name>
+    <uid>9FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1</uid>
     <password>managers</password>
-    <name>Managers</name>
-    <members>
-      <member type="users">lecroy</member>
-    </members>
-  </group>
-  <group>
+    <full-name>Managers</full-name>
+      <member-uid>lecroy</member-uid>
+  </record>
+  <record type="group">
+    <short-name>admin</short-name>
     <uid>admin</uid>
-    <guid>admin</guid>
     <password>admin</password>
-    <name>Administrators</name>
-    <members>
-      <member type="groups">managers</member>
-    </members>
-  </group>
-  <group>
+    <full-name>Administrators</full-name>
+      <member-uid>managers</member-uid>
+  </record>
+  <record type="group">
+    <short-name>grunts</short-name>
     <uid>grunts</uid>
-    <guid>grunts</guid>
     <password>grunts</password>
-    <name>We do all the work</name>
-    <members>
-      <member>wsanchez</member>
-      <member>cdaboo</member>
-      <member>dreid</member>
-    </members>
-  </group>
-  <group>
+    <full-name>We do all the work</full-name>
+      <member-uid>wsanchez</member-uid>
+      <member-uid>cdaboo</member-uid>
+      <member-uid>dreid</member-uid>
+  </record>
+  <record type="group">
+    <short-name>right_coast</short-name>
     <uid>right_coast</uid>
-    <guid>right_coast</guid>
     <password>right_coast</password>
-    <name>East Coast</name>
-    <members>
-      <member>cdaboo</member>
-    </members>
-  </group>
-  <group>
+    <full-name>East Coast</full-name>
+      <member-uid>cdaboo</member-uid>
+  </record>
+  <record type="group">
+    <short-name>left_coast</short-name>
     <uid>left_coast</uid>
-    <guid>left_coast</guid>
     <password>left_coast</password>
-    <name>West Coast</name>
-    <members>
-      <member>wsanchez</member>
-      <member>lecroy</member>
-      <member>dreid</member>
-    </members>
-  </group>
-  <group>
+    <full-name>West Coast</full-name>
+      <member-uid>wsanchez</member-uid>
+      <member-uid>lecroy</member-uid>
+      <member-uid>dreid</member-uid>
+  </record>
+  <record type="group">
+    <short-name>both_coasts</short-name>
     <uid>both_coasts</uid>
-    <guid>both_coasts</guid>
     <password>both_coasts</password>
-    <name>Both Coasts</name>
-    <members>
-      <member type="groups">right_coast</member>
-      <member type="groups">left_coast</member>
-    </members>
-  </group>
-  <group>
+    <full-name>Both Coasts</full-name>
+      <member-uid>right_coast</member-uid>
+      <member-uid>left_coast</member-uid>
+  </record>
+  <record type="group">
+    <short-name>recursive1_coasts</short-name>
     <uid>recursive1_coasts</uid>
-    <guid>recursive1_coasts</guid>
     <password>recursive1_coasts</password>
-    <name>Recursive1 Coasts</name>
-    <members>
-      <member type="groups">recursive2_coasts</member>
-      <member>wsanchez</member>
-    </members>
-  </group>
-  <group>
+    <full-name>Recursive1 Coasts</full-name>
+      <member-uid>recursive2_coasts</member-uid>
+      <member-uid>wsanchez</member-uid>
+  </record>
+  <record type="group">
+    <short-name>recursive2_coasts</short-name>
     <uid>recursive2_coasts</uid>
-    <guid>recursive2_coasts</guid>
     <password>recursive2_coasts</password>
-    <name>Recursive2 Coasts</name>
-    <members>
-      <member type="groups">recursive1_coasts</member>
-      <member>cdaboo</member>
-    </members>
-  </group>
-  <group>
+    <full-name>Recursive2 Coasts</full-name>
+      <member-uid>recursive1_coasts</member-uid>
+      <member-uid>cdaboo</member-uid>
+  </record>
+  <record type="group">
+    <short-name>non_calendar_group</short-name>
     <uid>non_calendar_group</uid>
-    <guid>non_calendar_group</guid>
     <password>non_calendar_group</password>
-    <name>Non-calendar group</name>
-    <members>
-      <member>cdaboo</member>
-      <member>lecroy</member>
-    </members>
-  </group>
+    <full-name>Non-calendar group</full-name>
+      <member-uid>cdaboo</member-uid>
+      <member-uid>lecroy</member-uid>
+  </record>
+  <!--
   <location>
     <uid>mercury</uid>
-    <guid>mercury</guid>
+    <uid>mercury</uid>
     <password>mercury</password>
     <name>Mercury Seven</name>
     <email-address>mercury at example.com</email-address>
   </location>
   <location>
     <uid>gemini</uid>
-    <guid>gemini</guid>
+    <uid>gemini</uid>
     <password>gemini</password>
     <name>Gemini Twelve</name>
     <email-address>gemini at example.com</email-address>
   </location>
   <location>
     <uid>apollo</uid>
-    <guid>apollo</guid>
+    <uid>apollo</uid>
     <password>apollo</password>
     <name>Apollo Eleven</name>
     <email-address>apollo at example.com</email-address>
   </location>
   <location>
     <uid>orion</uid>
-    <guid>orion</guid>
+    <uid>orion</uid>
     <password>orion</password>
     <name>Orion</name>
     <email-address>orion at example.com</email-address>
   </location>
   <resource>
     <uid>transporter</uid>
-    <guid>transporter</guid>
+    <uid>transporter</uid>
     <password>transporter</password>
     <name>Mass Transporter</name>
     <email-address>transporter at example.com</email-address>
   </resource>
   <resource>
     <uid>ftlcpu</uid>
-    <guid>ftlcpu</guid>
+    <uid>ftlcpu</uid>
     <password>ftlcpu</password>
     <name>Faster-Than-Light Microprocessor</name>
     <email-address>ftlcpu at example.com</email-address>
   </resource>
   <resource>
     <uid>non_calendar_proxy</uid>
-    <guid>non_calendar_proxy</guid>
+    <uid>non_calendar_proxy</uid>
     <password>non_calendar_proxy</password>
     <name>Non-calendar proxy</name>
     <email-address>non_calendar_proxy at example.com</email-address>
   </resource>
   <resource>
     <uid>disabled</uid>
-    <guid>disabled</guid>
+    <uid>disabled</uid>
     <password>disabled</password>
     <name>Disabled Record</name>
     <email-address>disabled at example.com</email-address>
   </resource>
-</accounts>
+-->
+</directory>

Modified: CalendarServer/branches/users/sagen/move2who-2/twistedcaldav/test/util.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-2/twistedcaldav/test/util.py	2014-03-10 17:52:25 UTC (rev 12864)
+++ CalendarServer/branches/users/sagen/move2who-2/twistedcaldav/test/util.py	2014-03-10 18:19:32 UTC (rev 12865)
@@ -17,46 +17,41 @@
 from __future__ import with_statement
 
 import os
-import xattr
 
-from twistedcaldav.stdconfig import config
-
-from twisted.python.failure import Failure
+from calendarserver.provision.root import RootResource
+from calendarserver.tap.util import getRootResource
+from twext.python.filepath import CachingFilePath as FilePath
+from twext.python.log import Logger
 from twisted.internet.base import DelayedCall
 from twisted.internet.defer import succeed, fail, inlineCallbacks, returnValue
 from twisted.internet.protocol import ProcessProtocol
-
-from twext.python.filepath import CachingFilePath as FilePath
-import txweb2.dav.test.util
-from txdav.xml import element as davxml, element
-from txweb2.http import HTTPError, StatusResponse
-
+from twisted.python.failure import Failure
 from twistedcaldav import memcacher
-from twistedcaldav.memcacheclient import ClientFactory
 from twistedcaldav.bind import doBind
 from twistedcaldav.directory import augment
 from twistedcaldav.directory.addressbook import DirectoryAddressBookHomeProvisioningResource
+from twistedcaldav.directory.aggregate import AggregateDirectoryService
 from twistedcaldav.directory.calendar import (
     DirectoryCalendarHomeProvisioningResource
 )
+from twistedcaldav.directory.directory import DirectoryService
 from twistedcaldav.directory.principal import (
     DirectoryPrincipalProvisioningResource)
-from twistedcaldav.directory.aggregate import AggregateDirectoryService
+from twistedcaldav.directory.util import transactionFromRequest
 from twistedcaldav.directory.xmlfile import XMLDirectoryService
-
+from twistedcaldav.memcacheclient import ClientFactory
+from twistedcaldav.stdconfig import config
+from txdav.caldav.datastore.test.util import buildCalendarStore
+from txdav.common.datastore.file import CommonDataStore
 from txdav.common.datastore.test.util import deriveQuota, CommonCommonTests
-from txdav.common.datastore.file import CommonDataStore
+from txdav.dps.server import directoryFromConfig
+from txdav.xml import element as davxml, element
+from txweb2.dav.test.util import SimpleRequest
+import txweb2.dav.test.util
+from txweb2.http import HTTPError, StatusResponse
+import xattr
 
-from calendarserver.provision.root import RootResource
 
-from twext.python.log import Logger
-from calendarserver.tap.util import getRootResource
-from txweb2.dav.test.util import SimpleRequest
-from twistedcaldav.directory.util import transactionFromRequest
-from twistedcaldav.directory.directory import DirectoryService
-from txdav.caldav.datastore.test.util import buildCalendarStore
-from txdav.dps.server import directoryFromConfig
-
 log = Logger()
 
 
@@ -68,10 +63,12 @@
 ]
 DelayedCall.debug = True
 
+
 def _todo(f, why):
     f.todo = why
     return f
 
+
 featureUnimplemented = lambda f: _todo(f, "Feature unimplemented")
 testUnimplemented = lambda f: _todo(f, "Test unimplemented")
 todo = lambda why: lambda f: _todo(f, why)
@@ -199,9 +196,13 @@
 
         self.configure()
 
-        self._sqlCalendarStore = yield buildCalendarStore(self, self.notifierFactory, directoryFromConfig(config))
+        self._sqlCalendarStore = yield buildCalendarStore(
+            self, self.notifierFactory, None
+        )
+        self.directory = directoryFromConfig(config, self._sqlCalendarStore)
+        self._sqlCalendarStore.setDirectoryService(self.directory)
+
         self.rootResource = getRootResource(config, self._sqlCalendarStore)
-        self.directory = self._sqlCalendarStore.directoryService()
 
         self.principalsResource = DirectoryPrincipalProvisioningResource("/principals/", self.directory)
         self.site.resource.putChild("principals", self.principalsResource)
@@ -289,11 +290,16 @@
         """
         self.xmlFile = FilePath(config.DataRoot).child("accounts.xml")
         self.xmlFile.setContent(xmlFile.getContent())
-        self.directoryFixture.addDirectoryService(XMLDirectoryService({
-            "xmlFile": "accounts.xml",
-            "augmentService":
-                augment.AugmentXMLDB(xmlFiles=(augmentsFile.path,)),
-        }))
+        self.directoryFixture.addDirectoryService(
+            XMLDirectoryService(
+                {
+                    "xmlFile": "accounts.xml",
+                    "augmentService": augment.AugmentXMLDB(
+                        xmlFiles=(augmentsFile.path,)
+                    ),
+                }
+            )
+        )
 
 
     def setupCalendars(self):
@@ -309,6 +315,8 @@
         L{TestCase.directoryFixture.addDirectoryService}.
         """
         newStore = self.createDataStore()
+
+
         @self.directoryFixture.whenDirectoryServiceChanges
         def putAllChildren(ds):
             self.calendarCollection = (
@@ -507,7 +515,7 @@
                                     print("Xattr mismatch:", childPath, attr)
                                     print((xattr.getxattr(childPath, attr), " != ", value))
                                     return False
-                            else: # method
+                            else:  # method
                                 if not value(xattr.getxattr(childPath, attr)):
                                     return False
 
@@ -557,6 +565,8 @@
         """
         super(HomeTestCase, self).setUp()
         self.createStockDirectoryService()
+
+
         @self.directoryFixture.whenDirectoryServiceChanges
         def addHomeProvisioner(ds):
             self.homeProvisioner = DirectoryCalendarHomeProvisioningResource(
@@ -641,6 +651,8 @@
         """
         super(AddressBookHomeTestCase, self).setUp()
         self.createStockDirectoryService()
+
+
         @self.directoryFixture.whenDirectoryServiceChanges
         def addHomeProvisioner(ds):
             self.homeProvisioner = DirectoryAddressBookHomeProvisioningResource(

Modified: CalendarServer/branches/users/sagen/move2who-2/txdav/dps/server.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-2/txdav/dps/server.py	2014-03-10 17:52:25 UTC (rev 12864)
+++ CalendarServer/branches/users/sagen/move2who-2/txdav/dps/server.py	2014-03-10 18:19:32 UTC (rev 12865)
@@ -34,7 +34,7 @@
 from twisted.python.filepath import FilePath
 from twisted.python.reflect import namedClass
 from twisted.python.usage import Options, UsageError
-from twistedcaldav.config import config
+from twistedcaldav.config import config, fullServerPath
 from twistedcaldav.stdconfig import DEFAULT_CONFIG, DEFAULT_CONFIG_FILE
 from txdav.dps.commands import (
     RecordWithShortNameCommand, RecordWithUIDCommand, RecordWithGUIDCommand,
@@ -421,44 +421,64 @@
 
 def directoryFromConfig(config, store=None):
     """
-    Return a directory service based on the config
+    Return a directory service based on the config.  If you want to go through
+    AMP to talk to one of these as a client, instantiate
+    txdav.dps.client.DirectoryService
     """
-    directoryType = config.DirectoryProxy.DirectoryType
-    args = config.DirectoryProxy.Arguments
-    kwds = config.DirectoryProxy.Keywords
 
-    # FIXME: this needs to talk to its own separate database
+    # FIXME: this needs to talk to its own separate database.  In fact,
+    # don't pass store=None if you already have called storeFromConfig()
+    # within this process.  Pass the existing store in here.
     pool, txnFactory = getDBPool(config)
     if store is None:
         store = storeFromConfig(config, txnFactory, None)
 
-    if directoryType == "OD":
-        from twext.who.opendirectory import DirectoryService as ODDirectoryService
-        primaryDirectory = ODDirectoryService(*args, **kwds)
+    # directoryType = config.DirectoryProxy.DirectoryType
+    directoryType = config.DirectoryService.type
 
-    elif directoryType == "LDAP":
-        authDN = kwds.pop("authDN", "")
-        password = kwds.pop("password", "")
-        if authDN and password:
-            creds = UsernamePassword(authDN, password)
-        else:
-            creds = None
-        kwds["credentials"] = creds
-        debug = kwds.pop("debug", "")
-        primaryDirectory = LDAPDirectoryService(
-            *args, _debug=debug, **kwds
-        )
+    if "XML" in directoryType:
+        xmlFile = config.DirectoryService.params.xmlFile
+        xmlFile = fullServerPath(config.DataRoot, xmlFile)
+        # path = kwds.pop("path", "")
+        if not xmlFile or not os.path.exists(xmlFile):
+            log.error("Path not found for XML directory: {p}", p=xmlFile)
+        fp = FilePath(xmlFile)
+        primaryDirectory = XMLDirectoryService(fp)
 
-    elif directoryType == "XML":
-        path = kwds.pop("path", "")
-        if not path or not os.path.exists(path):
-            log.error("Path not found for XML directory: {p}", p=path)
-        fp = FilePath(path)
-        primaryDirectory = XMLDirectoryService(fp, *args, **kwds)
 
-    else:
-        log.error("Invalid DirectoryType: {dt}", dt=directoryType)
+    # FIXME: implement the other service types
 
+    # args = config.DirectoryProxy.Arguments
+    # kwds = config.DirectoryProxy.Keywords
+
+
+    # if directoryType == "OD":
+    #     from twext.who.opendirectory import DirectoryService as ODDirectoryService
+    #     primaryDirectory = ODDirectoryService(*args, **kwds)
+
+    # elif directoryType == "LDAP":
+    #     authDN = kwds.pop("authDN", "")
+    #     password = kwds.pop("password", "")
+    #     if authDN and password:
+    #         creds = UsernamePassword(authDN, password)
+    #     else:
+    #         creds = None
+    #     kwds["credentials"] = creds
+    #     debug = kwds.pop("debug", "")
+    #     primaryDirectory = LDAPDirectoryService(
+    #         *args, _debug=debug, **kwds
+    #     )
+
+    # elif directoryType == "XML":
+    #     path = kwds.pop("path", "")
+    #     if not path or not os.path.exists(path):
+    #         log.error("Path not found for XML directory: {p}", p=path)
+    #     fp = FilePath(path)
+    #     primaryDirectory = XMLDirectoryService(fp, *args, **kwds)
+
+    # else:
+    #     log.error("Invalid DirectoryType: {dt}", dt=directoryType)
+
     #
     # Setup the Augment Service
     #
@@ -522,15 +542,12 @@
             setproctitle("CalendarServer Directory Proxy Service")
 
         try:
-            print("XZZZY AAA")
             directory = directoryFromConfig(config)
-            print("XZZZY BBB")
         except Exception as e:
             log.error("Failed to create directory service", error=e)
             raise
 
         log.info("Created directory service")
-        print("XZZZY CCCC")
 
         return strPortsService(
             "unix:{path}:mode=660".format(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140310/7941c1f7/attachment-0001.html>


More information about the calendarserver-changes mailing list