[CalendarServer-changes] [5237] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 3 16:37:56 PST 2010


Revision: 5237
          http://trac.macosforge.org/projects/calendarserver/changeset/5237
Author:   wsanchez at apple.com
Date:     2010-03-03 16:37:56 -0800 (Wed, 03 Mar 2010)
Log Message:
-----------
calendarserver.util -> calendarserver.tap.util

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/sidecar/task.py
    CalendarServer/trunk/calendarserver/tap/caldav.py
    CalendarServer/trunk/calendarserver/tools/purge.py
    CalendarServer/trunk/calendarserver/tools/test/test_purge.py
    CalendarServer/trunk/twistedcaldav/mail.py

Added Paths:
-----------
    CalendarServer/trunk/calendarserver/tap/util.py

Removed Paths:
-------------
    CalendarServer/trunk/calendarserver/util.py

Modified: CalendarServer/trunk/calendarserver/sidecar/task.py
===================================================================
--- CalendarServer/trunk/calendarserver/sidecar/task.py	2010-03-04 00:34:18 UTC (rev 5236)
+++ CalendarServer/trunk/calendarserver/sidecar/task.py	2010-03-04 00:37:56 UTC (rev 5237)
@@ -42,7 +42,7 @@
 from twistedcaldav.scheduling.cuaddress import LocalCalendarUser
 from twistedcaldav.scheduling.scheduler import DirectScheduler
 
-from calendarserver.util import getRootResource, FakeRequest
+from calendarserver.tap.util import getRootResource, FakeRequest
 from calendarserver.tools.purge import purgeOldEvents
 
 log = Logger()

Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py	2010-03-04 00:34:18 UTC (rev 5236)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py	2010-03-04 00:37:56 UTC (rev 5237)
@@ -84,7 +84,7 @@
 from calendarserver.provision.root import RootResource
 from calendarserver.webadmin.resource import WebAdminResource
 from calendarserver.webcal.resource import WebCalendarResource
-from calendarserver.util import getRootResource
+from calendarserver.tap.util import getRootResource
 
 log = Logger()
 

Copied: CalendarServer/trunk/calendarserver/tap/util.py (from rev 5236, CalendarServer/trunk/calendarserver/util.py)
===================================================================
--- CalendarServer/trunk/calendarserver/tap/util.py	                        (rev 0)
+++ CalendarServer/trunk/calendarserver/tap/util.py	2010-03-04 00:37:56 UTC (rev 5237)
@@ -0,0 +1,480 @@
+# -*- test-case-name: calendarserver.tap.test.test_caldav -*-
+##
+# Copyright (c) 2005-2010 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+__all__ = [
+    "getRootResource",
+    "FakeRequest",
+]
+
+import errno
+import os
+from time import sleep
+
+from twisted.python.reflect import namedClass
+from twisted.internet import reactor
+from twisted.cred.portal import Portal
+from twext.web2.http_headers import Headers
+from twext.web2.dav import auth
+from twext.web2.auth.basic import BasicCredentialFactory
+from twext.web2.static import File as FileResource
+from twext.python.filepath import CachingFilePath as FilePath
+
+from twext.python.log import Logger
+
+from twistedcaldav import memcachepool
+from twistedcaldav.directory import augment, calendaruserproxy
+from twistedcaldav.directory.aggregate import AggregateDirectoryService
+from twistedcaldav.directory.calendaruserproxyloader import XMLCalendarUserProxyLoader
+from twistedcaldav.directory.digest import QopDigestCredentialFactory
+from twistedcaldav.directory.principal import DirectoryPrincipalProvisioningResource
+from twistedcaldav.directory.sudo import SudoDirectoryService
+from twistedcaldav.directory.util import NotFilePath
+from twistedcaldav.directory.wiki import WikiDirectoryService
+from twistedcaldav.notify import installNotificationClient
+from twistedcaldav.resource import CalDAVResource, AuthenticationWrapper
+from twistedcaldav.static import CalendarHomeProvisioningFile
+from twistedcaldav.static import IScheduleInboxFile
+from twistedcaldav.static import TimezoneServiceFile
+from twistedcaldav.static import AddressBookHomeProvisioningFile, DirectoryBackedAddressBookFile
+from twistedcaldav.timezones import TimezoneCache
+from twisted.internet.defer import inlineCallbacks, returnValue
+
+try:
+    from twistedcaldav.authkerb import NegotiateCredentialFactory
+    NegotiateCredentialFactory  # pacify pyflakes
+except ImportError:
+    NegotiateCredentialFactory = None
+
+from calendarserver.accesslog import DirectoryLogWrapperResource
+from calendarserver.provision.root import RootResource
+from calendarserver.webadmin.resource import WebAdminResource
+from calendarserver.webcal.resource import WebCalendarResource
+
+log = Logger()
+
+
+
+def getRootResource(config, resources=None):
+    """
+    Set up directory service and resource hierarchy based on config.
+    Return root resource.
+
+    Additional resources can be added to the hierarchy by passing a list of
+    tuples containing: path, resource class, __init__ args list, and optional
+    authentication scheme ("basic" or "digest").
+    """
+
+    #
+    # Default resource classes
+    #
+    rootResourceClass            = RootResource
+    principalResourceClass       = DirectoryPrincipalProvisioningResource
+    calendarResourceClass        = CalendarHomeProvisioningFile
+    iScheduleResourceClass       = IScheduleInboxFile
+    timezoneServiceResourceClass = TimezoneServiceFile
+    webCalendarResourceClass     = WebCalendarResource
+    webAdminResourceClass        = WebAdminResource
+    addressBookResourceClass     = AddressBookHomeProvisioningFile
+    directoryBackedAddressBookResourceClass = DirectoryBackedAddressBookFile
+
+    #
+    # Setup the Directory
+    #
+    directories = []
+
+    directoryClass = namedClass(config.DirectoryService.type)
+
+    log.info("Configuring directory service of type: %s"
+        % (config.DirectoryService.type,))
+
+    baseDirectory = directoryClass(config.DirectoryService.params)
+
+    # Wait for the directory to become available
+    while not baseDirectory.isAvailable():
+        sleep(5)
+
+    directories.append(baseDirectory)
+
+    #
+    # Setup the Locations and Resources Service
+    #
+    if config.ResourceService.Enabled:
+        resourceClass = namedClass(config.ResourceService.type)
+
+        log.info("Configuring resource service of type: %s" % (resourceClass,))
+
+        resourceDirectory = resourceClass(config.ResourceService.params)
+        directories.append(resourceDirectory)
+
+    #
+    # Add sudoers directory
+    #
+    sudoDirectory = None
+
+    if config.SudoersFile and os.path.exists(config.SudoersFile):
+        log.info("Configuring SudoDirectoryService with file: %s"
+                      % (config.SudoersFile,))
+
+        sudoDirectory = SudoDirectoryService(config.SudoersFile)
+        sudoDirectory.realmName = baseDirectory.realmName
+
+        CalDAVResource.sudoDirectory = sudoDirectory
+        directories.insert(0, sudoDirectory)
+    else:
+        log.info( "Not using SudoDirectoryService; file doesn't exist: %s"
+            % (config.SudoersFile,)
+        )
+
+    #
+    # Add wiki directory service
+    #
+    if config.Authentication.Wiki.Enabled:
+        wikiDirectory = WikiDirectoryService()
+        wikiDirectory.realmName = baseDirectory.realmName
+        directories.append(wikiDirectory)
+
+    directory = AggregateDirectoryService(directories)
+
+    if sudoDirectory:
+        directory.userRecordTypes.insert(0,
+            SudoDirectoryService.recordType_sudoers)
+
+    #
+    # Setup the Augment Service
+    #
+    augmentClass = namedClass(config.AugmentService.type)
+
+    log.info("Configuring augment service of type: %s" % (augmentClass,))
+
+    try:
+        augment.AugmentService = augmentClass(**config.AugmentService.params)
+    except IOError:
+        log.error("Could not start augment service")
+        raise
+
+    #
+    # Setup the PoxyDB Service
+    #
+    proxydbClass = namedClass(config.ProxyDBService.type)
+
+    log.info("Configuring proxydb service of type: %s" % (proxydbClass,))
+
+    try:
+        calendaruserproxy.ProxyDBService = proxydbClass(**config.ProxyDBService.params)
+    except IOError:
+        log.error("Could not start proxydb service")
+        raise
+
+    #
+    # Make sure proxies get initialized
+    #
+    if config.ProxyLoadFromFile:
+        def _doProxyUpdate():
+            loader = XMLCalendarUserProxyLoader(config.ProxyLoadFromFile)
+            return loader.updateProxyDB()
+
+        reactor.addSystemEventTrigger("after", "startup", _doProxyUpdate)
+
+    #
+    # Configure Memcached Client Pool
+    #
+    memcachepool.installPools(
+        config.Memcached.Pools,
+        config.Memcached.MaxClients,
+    )
+
+    #
+    # Configure NotificationClient
+    #
+    if config.Notifications.Enabled:
+        installNotificationClient(
+            config.Notifications.InternalNotificationHost,
+            config.Notifications.InternalNotificationPort,
+        )
+
+    #
+    # Configure the Site and Wrappers
+    #
+    credentialFactories = []
+
+    portal = Portal(auth.DavRealm())
+
+    portal.registerChecker(directory)
+
+    realm = directory.realmName or ""
+
+    log.info("Configuring authentication for realm: %s" % (realm,))
+
+    for scheme, schemeConfig in config.Authentication.iteritems():
+        scheme = scheme.lower()
+
+        credFactory = None
+
+        if schemeConfig["Enabled"]:
+            log.info("Setting up scheme: %s" % (scheme,))
+
+            if scheme == "kerberos":
+                if not NegotiateCredentialFactory:
+                    log.info("Kerberos support not available")
+                    continue
+
+                try:
+                    principal = schemeConfig["ServicePrincipal"]
+                    if not principal:
+                        credFactory = NegotiateCredentialFactory(
+                            type="HTTP",
+                            hostname=config.ServerHostName,
+                        )
+                    else:
+                        credFactory = NegotiateCredentialFactory(
+                            principal=principal,
+                        )
+                except ValueError:
+                    log.info("Could not start Kerberos")
+                    continue
+
+            elif scheme == "digest":
+                credFactory = QopDigestCredentialFactory(
+                    schemeConfig["Algorithm"],
+                    schemeConfig["Qop"],
+                    realm,
+                )
+
+            elif scheme == "basic":
+                credFactory = BasicCredentialFactory(realm)
+
+            elif scheme == "wiki":
+                pass
+
+            else:
+                log.error("Unknown scheme: %s" % (scheme,))
+
+        if credFactory:
+            credentialFactories.append(credFactory)
+
+
+    #
+    # Setup Resource hierarchy
+    #
+    log.info("Setting up document root at: %s"
+                  % (config.DocumentRoot,))
+    log.info("Setting up principal collection: %r"
+                  % (principalResourceClass,))
+
+    principalCollection = principalResourceClass("/principals/", directory)
+
+    log.info("Setting up calendar collection: %r" % (calendarResourceClass,))
+
+    calendarCollection = calendarResourceClass(
+        os.path.join(config.DocumentRoot, "calendars"),
+        directory, "/calendars/",
+    )
+
+    log.info("Setting up root resource: %r" % (rootResourceClass,))
+
+    root = rootResourceClass(
+        config.DocumentRoot,
+        principalCollections=(principalCollection,),
+    )
+
+    if config.EnableCardDAV:
+        root.saclService = "addressbook" # XXX this needs to be dealt with
+                                         # differently if caldav and carddav
+                                         # are going to be in the same process
+        log.info("Setting up address book collection: %r" % (addressBookResourceClass,))
+
+        addressBookCollection = addressBookResourceClass(
+            os.path.join(config.DocumentRoot, "addressbooks"),
+            directory, "/addressbooks/"
+        )
+
+        directoryPath = os.path.join(config.DocumentRoot, "directory")
+        doBacking = config.DirectoryAddressBook and config.EnableSearchAddressBook
+        if doBacking:
+            log.info("Setting up directory address book: %r" % (directoryBackedAddressBookResourceClass,))
+
+            directoryBackedAddressBookCollection = directoryBackedAddressBookResourceClass(
+                directoryPath,
+                principalCollections=(principalCollection,)
+            )
+            # do this after process is owned by carddav user, not root.  XXX
+            # this should be fixed to execute at a different stage of service
+            # startup entirely.
+            reactor.callLater(1.0, directoryBackedAddressBookCollection.provisionDirectory)
+        else:
+            # remove /directory from previous runs that may have created it
+            try:
+                FilePath(directoryPath).remove()
+                log.info("Deleted: %s" %    directoryPath)
+            except (OSError, IOError), e:
+                if e.errno != errno.ENOENT:
+                    log.error("Could not delete: %s : %r" %  (directoryPath, e,))
+
+        root.putChild('addressbooks', addressBookCollection)
+        if doBacking:
+            root.putChild('directory', directoryBackedAddressBookCollection)
+
+    root.putChild("principals", principalCollection)
+    root.putChild("calendars", calendarCollection)
+
+    for name, info in config.Aliases.iteritems():
+        if os.path.sep in name or not info.get("path", None):
+            log.error("Invalid alias: %s" % (name,))
+            continue
+        log.info("Adding alias %s -> %s" % (name, info["path"]))
+        resource = FileResource(info["path"])
+        root.putChild(name, resource)
+
+    # Timezone service is optional
+    if config.EnableTimezoneService:
+        log.info("Setting up time zone service resource: %r"
+                      % (timezoneServiceResourceClass,))
+
+        timezoneService = timezoneServiceResourceClass(
+            NotFilePath(isfile=True),
+            root,
+        )
+        root.putChild("timezones", timezoneService)
+
+    # iSchedule service is optional
+    if config.Scheduling.iSchedule.Enabled:
+        log.info("Setting up iSchedule inbox resource: %r"
+                      % (iScheduleResourceClass,))
+
+        ischedule = iScheduleResourceClass(
+            NotFilePath(isfile=True),
+            root,
+        )
+        root.putChild("ischedule", ischedule)
+
+    #
+    # WebCal
+    #
+    if config.WebCalendarRoot:
+        log.info("Setting up WebCalendar resource: %s"
+                      % (config.WebCalendarRoot,))
+        webCalendar = webCalendarResourceClass(
+            config.WebCalendarRoot,
+            principalCollections=(principalCollection,),
+        )
+        root.putChild("webcal", webCalendar)
+
+    #
+    # WebAdmin
+    #
+    if config.EnableWebAdmin:
+        log.info("Setting up WebAdmin resource")
+        webAdmin = webAdminResourceClass(
+            config.WebCalendarRoot,
+            root,
+            directory,
+            principalCollections=(principalCollection,),
+        )
+        root.putChild("admin", webAdmin)
+
+    #
+    # Configure ancillary data
+    #
+    log.info("Setting up Timezone Cache")
+    TimezoneCache.create()
+
+
+    log.info("Configuring authentication wrapper")
+
+    overrides = { }
+    if resources:
+        for path, cls, args, scheme in resources:
+
+            # putChild doesn't want "/" starting the path
+            root.putChild(path, cls(root, *args))
+
+            # overrides requires "/" prepended
+            path = "/" + path
+
+            if scheme == "basic":
+                overrides[path] = (BasicCredentialFactory(realm),)
+
+            elif scheme == "digest":
+                schemeConfig = config.Authentication.Digest
+                overrides[path] = (QopDigestCredentialFactory(
+                    schemeConfig["Algorithm"],
+                    schemeConfig["Qop"],
+                    realm,
+                ),)
+            log.info("Overriding %s with %s (%s)" % (path, cls, scheme))
+
+    authWrapper = AuthenticationWrapper(
+        root,
+        portal,
+        credentialFactories,
+        (auth.IPrincipal,),
+        overrides=overrides,
+    )
+
+    logWrapper = DirectoryLogWrapperResource(
+        authWrapper,
+        directory,
+    )
+
+    return logWrapper
+
+
+
+
+class FakeRequest(object):
+
+    def __init__(self, rootResource, method, path):
+        self.rootResource = rootResource
+        self.method = method
+        self.path = path
+        self._resourcesByURL = {}
+        self._urlsByResource = {}
+        self.headers = Headers()
+
+    @inlineCallbacks
+    def _getChild(self, resource, segments):
+        if not segments:
+            returnValue(resource)
+
+        child, remaining = (yield resource.locateChild(self, segments))
+        returnValue((yield self._getChild(child, remaining)))
+
+    @inlineCallbacks
+    def locateResource(self, url):
+        url = url.strip("/")
+        segments = url.split("/")
+        resource = (yield self._getChild(self.rootResource, segments))
+        if resource:
+            self._rememberResource(resource, url)
+        returnValue(resource)
+
+    def _rememberResource(self, resource, url):
+        self._resourcesByURL[url] = resource
+        self._urlsByResource[resource] = url
+        return resource
+
+    def urlForResource(self, resource):
+        url = self._urlsByResource.get(resource, None)
+        if url is None:
+            class NoURLForResourceError(RuntimeError):
+                pass
+            raise NoURLForResourceError(resource)
+        return url
+
+    def addResponseFilter(*args, **kwds):
+        pass
+

Modified: CalendarServer/trunk/calendarserver/tools/purge.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/purge.py	2010-03-04 00:34:18 UTC (rev 5236)
+++ CalendarServer/trunk/calendarserver/tools/purge.py	2010-03-04 00:37:56 UTC (rev 5237)
@@ -22,7 +22,7 @@
 from twistedcaldav.ical import Component as iComponent
 from twistedcaldav.method.delete_common import DeleteResource
 from twisted.internet.defer import inlineCallbacks, returnValue
-from calendarserver.util import FakeRequest
+from calendarserver.tap.util import FakeRequest
 
 log = Logger()
 

Modified: CalendarServer/trunk/calendarserver/tools/test/test_purge.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/test/test_purge.py	2010-03-04 00:34:18 UTC (rev 5236)
+++ CalendarServer/trunk/calendarserver/tools/test/test_purge.py	2010-03-04 00:37:56 UTC (rev 5237)
@@ -23,7 +23,7 @@
 
 from twistedcaldav.config import config
 from twistedcaldav.test.util import TestCase
-from calendarserver.util import getRootResource
+from calendarserver.tap.util import getRootResource
 from calendarserver.tools.purge import purgeOldEvents
 
 resourceAttr = "WebDAV:{DAV:}resourcetype"

Deleted: CalendarServer/trunk/calendarserver/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/util.py	2010-03-04 00:34:18 UTC (rev 5236)
+++ CalendarServer/trunk/calendarserver/util.py	2010-03-04 00:37:56 UTC (rev 5237)
@@ -1,480 +0,0 @@
-# -*- test-case-name: calendarserver.tap.test.test_caldav -*-
-##
-# Copyright (c) 2005-2010 Apple Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##
-
-__all__ = [
-    "getRootResource",
-    "FakeRequest",
-]
-
-import errno
-import os
-from time import sleep
-
-from twisted.python.reflect import namedClass
-from twisted.internet import reactor
-from twisted.cred.portal import Portal
-from twext.web2.http_headers import Headers
-from twext.web2.dav import auth
-from twext.web2.auth.basic import BasicCredentialFactory
-from twext.web2.static import File as FileResource
-from twext.python.filepath import CachingFilePath as FilePath
-
-from twext.python.log import Logger
-
-from twistedcaldav import memcachepool
-from twistedcaldav.directory import augment, calendaruserproxy
-from twistedcaldav.directory.aggregate import AggregateDirectoryService
-from twistedcaldav.directory.calendaruserproxyloader import XMLCalendarUserProxyLoader
-from twistedcaldav.directory.digest import QopDigestCredentialFactory
-from twistedcaldav.directory.principal import DirectoryPrincipalProvisioningResource
-from twistedcaldav.directory.sudo import SudoDirectoryService
-from twistedcaldav.directory.util import NotFilePath
-from twistedcaldav.directory.wiki import WikiDirectoryService
-from twistedcaldav.notify import installNotificationClient
-from twistedcaldav.resource import CalDAVResource, AuthenticationWrapper
-from twistedcaldav.static import CalendarHomeProvisioningFile
-from twistedcaldav.static import IScheduleInboxFile
-from twistedcaldav.static import TimezoneServiceFile
-from twistedcaldav.static import AddressBookHomeProvisioningFile, DirectoryBackedAddressBookFile
-from twistedcaldav.timezones import TimezoneCache
-from twisted.internet.defer import inlineCallbacks, returnValue
-
-try:
-    from twistedcaldav.authkerb import NegotiateCredentialFactory
-    NegotiateCredentialFactory  # pacify pyflakes
-except ImportError:
-    NegotiateCredentialFactory = None
-
-from calendarserver.accesslog import DirectoryLogWrapperResource
-from calendarserver.provision.root import RootResource
-from calendarserver.webadmin.resource import WebAdminResource
-from calendarserver.webcal.resource import WebCalendarResource
-
-log = Logger()
-
-
-
-def getRootResource(config, resources=None):
-    """
-    Set up directory service and resource hierarchy based on config.
-    Return root resource.
-
-    Additional resources can be added to the hierarchy by passing a list of
-    tuples containing: path, resource class, __init__ args list, and optional
-    authentication scheme ("basic" or "digest").
-    """
-
-    #
-    # Default resource classes
-    #
-    rootResourceClass            = RootResource
-    principalResourceClass       = DirectoryPrincipalProvisioningResource
-    calendarResourceClass        = CalendarHomeProvisioningFile
-    iScheduleResourceClass       = IScheduleInboxFile
-    timezoneServiceResourceClass = TimezoneServiceFile
-    webCalendarResourceClass     = WebCalendarResource
-    webAdminResourceClass        = WebAdminResource
-    addressBookResourceClass     = AddressBookHomeProvisioningFile
-    directoryBackedAddressBookResourceClass = DirectoryBackedAddressBookFile
-
-    #
-    # Setup the Directory
-    #
-    directories = []
-
-    directoryClass = namedClass(config.DirectoryService.type)
-
-    log.info("Configuring directory service of type: %s"
-        % (config.DirectoryService.type,))
-
-    baseDirectory = directoryClass(config.DirectoryService.params)
-
-    # Wait for the directory to become available
-    while not baseDirectory.isAvailable():
-        sleep(5)
-
-    directories.append(baseDirectory)
-
-    #
-    # Setup the Locations and Resources Service
-    #
-    if config.ResourceService.Enabled:
-        resourceClass = namedClass(config.ResourceService.type)
-
-        log.info("Configuring resource service of type: %s" % (resourceClass,))
-
-        resourceDirectory = resourceClass(config.ResourceService.params)
-        directories.append(resourceDirectory)
-
-    #
-    # Add sudoers directory
-    #
-    sudoDirectory = None
-
-    if config.SudoersFile and os.path.exists(config.SudoersFile):
-        log.info("Configuring SudoDirectoryService with file: %s"
-                      % (config.SudoersFile,))
-
-        sudoDirectory = SudoDirectoryService(config.SudoersFile)
-        sudoDirectory.realmName = baseDirectory.realmName
-
-        CalDAVResource.sudoDirectory = sudoDirectory
-        directories.insert(0, sudoDirectory)
-    else:
-        log.info( "Not using SudoDirectoryService; file doesn't exist: %s"
-            % (config.SudoersFile,)
-        )
-
-    #
-    # Add wiki directory service
-    #
-    if config.Authentication.Wiki.Enabled:
-        wikiDirectory = WikiDirectoryService()
-        wikiDirectory.realmName = baseDirectory.realmName
-        directories.append(wikiDirectory)
-
-    directory = AggregateDirectoryService(directories)
-
-    if sudoDirectory:
-        directory.userRecordTypes.insert(0,
-            SudoDirectoryService.recordType_sudoers)
-
-    #
-    # Setup the Augment Service
-    #
-    augmentClass = namedClass(config.AugmentService.type)
-
-    log.info("Configuring augment service of type: %s" % (augmentClass,))
-
-    try:
-        augment.AugmentService = augmentClass(**config.AugmentService.params)
-    except IOError:
-        log.error("Could not start augment service")
-        raise
-
-    #
-    # Setup the PoxyDB Service
-    #
-    proxydbClass = namedClass(config.ProxyDBService.type)
-
-    log.info("Configuring proxydb service of type: %s" % (proxydbClass,))
-
-    try:
-        calendaruserproxy.ProxyDBService = proxydbClass(**config.ProxyDBService.params)
-    except IOError:
-        log.error("Could not start proxydb service")
-        raise
-
-    #
-    # Make sure proxies get initialized
-    #
-    if config.ProxyLoadFromFile:
-        def _doProxyUpdate():
-            loader = XMLCalendarUserProxyLoader(config.ProxyLoadFromFile)
-            return loader.updateProxyDB()
-
-        reactor.addSystemEventTrigger("after", "startup", _doProxyUpdate)
-
-    #
-    # Configure Memcached Client Pool
-    #
-    memcachepool.installPools(
-        config.Memcached.Pools,
-        config.Memcached.MaxClients,
-    )
-
-    #
-    # Configure NotificationClient
-    #
-    if config.Notifications.Enabled:
-        installNotificationClient(
-            config.Notifications.InternalNotificationHost,
-            config.Notifications.InternalNotificationPort,
-        )
-
-    #
-    # Configure the Site and Wrappers
-    #
-    credentialFactories = []
-
-    portal = Portal(auth.DavRealm())
-
-    portal.registerChecker(directory)
-
-    realm = directory.realmName or ""
-
-    log.info("Configuring authentication for realm: %s" % (realm,))
-
-    for scheme, schemeConfig in config.Authentication.iteritems():
-        scheme = scheme.lower()
-
-        credFactory = None
-
-        if schemeConfig["Enabled"]:
-            log.info("Setting up scheme: %s" % (scheme,))
-
-            if scheme == "kerberos":
-                if not NegotiateCredentialFactory:
-                    log.info("Kerberos support not available")
-                    continue
-
-                try:
-                    principal = schemeConfig["ServicePrincipal"]
-                    if not principal:
-                        credFactory = NegotiateCredentialFactory(
-                            type="HTTP",
-                            hostname=config.ServerHostName,
-                        )
-                    else:
-                        credFactory = NegotiateCredentialFactory(
-                            principal=principal,
-                        )
-                except ValueError:
-                    log.info("Could not start Kerberos")
-                    continue
-
-            elif scheme == "digest":
-                credFactory = QopDigestCredentialFactory(
-                    schemeConfig["Algorithm"],
-                    schemeConfig["Qop"],
-                    realm,
-                )
-
-            elif scheme == "basic":
-                credFactory = BasicCredentialFactory(realm)
-
-            elif scheme == "wiki":
-                pass
-
-            else:
-                log.error("Unknown scheme: %s" % (scheme,))
-
-        if credFactory:
-            credentialFactories.append(credFactory)
-
-
-    #
-    # Setup Resource hierarchy
-    #
-    log.info("Setting up document root at: %s"
-                  % (config.DocumentRoot,))
-    log.info("Setting up principal collection: %r"
-                  % (principalResourceClass,))
-
-    principalCollection = principalResourceClass("/principals/", directory)
-
-    log.info("Setting up calendar collection: %r" % (calendarResourceClass,))
-
-    calendarCollection = calendarResourceClass(
-        os.path.join(config.DocumentRoot, "calendars"),
-        directory, "/calendars/",
-    )
-
-    log.info("Setting up root resource: %r" % (rootResourceClass,))
-
-    root = rootResourceClass(
-        config.DocumentRoot,
-        principalCollections=(principalCollection,),
-    )
-
-    if config.EnableCardDAV:
-        root.saclService = "addressbook" # XXX this needs to be dealt with
-                                         # differently if caldav and carddav
-                                         # are going to be in the same process
-        log.info("Setting up address book collection: %r" % (addressBookResourceClass,))
-
-        addressBookCollection = addressBookResourceClass(
-            os.path.join(config.DocumentRoot, "addressbooks"),
-            directory, "/addressbooks/"
-        )
-
-        directoryPath = os.path.join(config.DocumentRoot, "directory")
-        doBacking = config.DirectoryAddressBook and config.EnableSearchAddressBook
-        if doBacking:
-            log.info("Setting up directory address book: %r" % (directoryBackedAddressBookResourceClass,))
-
-            directoryBackedAddressBookCollection = directoryBackedAddressBookResourceClass(
-                directoryPath,
-                principalCollections=(principalCollection,)
-            )
-            # do this after process is owned by carddav user, not root.  XXX
-            # this should be fixed to execute at a different stage of service
-            # startup entirely.
-            reactor.callLater(1.0, directoryBackedAddressBookCollection.provisionDirectory)
-        else:
-            # remove /directory from previous runs that may have created it
-            try:
-                FilePath(directoryPath).remove()
-                log.info("Deleted: %s" %    directoryPath)
-            except (OSError, IOError), e:
-                if e.errno != errno.ENOENT:
-                    log.error("Could not delete: %s : %r" %  (directoryPath, e,))
-
-        root.putChild('addressbooks', addressBookCollection)
-        if doBacking:
-            root.putChild('directory', directoryBackedAddressBookCollection)
-
-    root.putChild("principals", principalCollection)
-    root.putChild("calendars", calendarCollection)
-
-    for name, info in config.Aliases.iteritems():
-        if os.path.sep in name or not info.get("path", None):
-            log.error("Invalid alias: %s" % (name,))
-            continue
-        log.info("Adding alias %s -> %s" % (name, info["path"]))
-        resource = FileResource(info["path"])
-        root.putChild(name, resource)
-
-    # Timezone service is optional
-    if config.EnableTimezoneService:
-        log.info("Setting up time zone service resource: %r"
-                      % (timezoneServiceResourceClass,))
-
-        timezoneService = timezoneServiceResourceClass(
-            NotFilePath(isfile=True),
-            root,
-        )
-        root.putChild("timezones", timezoneService)
-
-    # iSchedule service is optional
-    if config.Scheduling.iSchedule.Enabled:
-        log.info("Setting up iSchedule inbox resource: %r"
-                      % (iScheduleResourceClass,))
-
-        ischedule = iScheduleResourceClass(
-            NotFilePath(isfile=True),
-            root,
-        )
-        root.putChild("ischedule", ischedule)
-
-    #
-    # WebCal
-    #
-    if config.WebCalendarRoot:
-        log.info("Setting up WebCalendar resource: %s"
-                      % (config.WebCalendarRoot,))
-        webCalendar = webCalendarResourceClass(
-            config.WebCalendarRoot,
-            principalCollections=(principalCollection,),
-        )
-        root.putChild("webcal", webCalendar)
-
-    #
-    # WebAdmin
-    #
-    if config.EnableWebAdmin:
-        log.info("Setting up WebAdmin resource")
-        webAdmin = webAdminResourceClass(
-            config.WebCalendarRoot,
-            root,
-            directory,
-            principalCollections=(principalCollection,),
-        )
-        root.putChild("admin", webAdmin)
-
-    #
-    # Configure ancillary data
-    #
-    log.info("Setting up Timezone Cache")
-    TimezoneCache.create()
-
-
-    log.info("Configuring authentication wrapper")
-
-    overrides = { }
-    if resources:
-        for path, cls, args, scheme in resources:
-
-            # putChild doesn't want "/" starting the path
-            root.putChild(path, cls(root, *args))
-
-            # overrides requires "/" prepended
-            path = "/" + path
-
-            if scheme == "basic":
-                overrides[path] = (BasicCredentialFactory(realm),)
-
-            elif scheme == "digest":
-                schemeConfig = config.Authentication.Digest
-                overrides[path] = (QopDigestCredentialFactory(
-                    schemeConfig["Algorithm"],
-                    schemeConfig["Qop"],
-                    realm,
-                ),)
-            log.info("Overriding %s with %s (%s)" % (path, cls, scheme))
-
-    authWrapper = AuthenticationWrapper(
-        root,
-        portal,
-        credentialFactories,
-        (auth.IPrincipal,),
-        overrides=overrides,
-    )
-
-    logWrapper = DirectoryLogWrapperResource(
-        authWrapper,
-        directory,
-    )
-
-    return logWrapper
-
-
-
-
-class FakeRequest(object):
-
-    def __init__(self, rootResource, method, path):
-        self.rootResource = rootResource
-        self.method = method
-        self.path = path
-        self._resourcesByURL = {}
-        self._urlsByResource = {}
-        self.headers = Headers()
-
-    @inlineCallbacks
-    def _getChild(self, resource, segments):
-        if not segments:
-            returnValue(resource)
-
-        child, remaining = (yield resource.locateChild(self, segments))
-        returnValue((yield self._getChild(child, remaining)))
-
-    @inlineCallbacks
-    def locateResource(self, url):
-        url = url.strip("/")
-        segments = url.split("/")
-        resource = (yield self._getChild(self.rootResource, segments))
-        if resource:
-            self._rememberResource(resource, url)
-        returnValue(resource)
-
-    def _rememberResource(self, resource, url):
-        self._resourcesByURL[url] = resource
-        self._urlsByResource[resource] = url
-        return resource
-
-    def urlForResource(self, resource):
-        url = self._urlsByResource.get(resource, None)
-        if url is None:
-            class NoURLForResourceError(RuntimeError):
-                pass
-            raise NoURLForResourceError(resource)
-        return url
-
-    def addResponseFilter(*args, **kwds):
-        pass
-

Modified: CalendarServer/trunk/twistedcaldav/mail.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/mail.py	2010-03-04 00:34:18 UTC (rev 5236)
+++ CalendarServer/trunk/twistedcaldav/mail.py	2010-03-04 00:37:56 UTC (rev 5237)
@@ -68,7 +68,7 @@
 from twistedcaldav.util import AuthorizedHTTPGetter
 from twistedcaldav.stdconfig import DEFAULT_CONFIG, DEFAULT_CONFIG_FILE
 
-from calendarserver.util import getRootResource
+from calendarserver.tap.util import getRootResource
 
 
 __all__ = [
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100303/3a59eede/attachment-0001.html>


More information about the calendarserver-changes mailing list