[CalendarServer-changes] [5023] CalendarServer/branches/users/glyph/contacts-server-merge

source_changes at macosforge.org source_changes at macosforge.org
Tue Feb 2 20:48:33 PST 2010


Revision: 5023
          http://trac.macosforge.org/projects/calendarserver/changeset/5023
Author:   glyph at apple.com
Date:     2010-02-02 20:48:30 -0800 (Tue, 02 Feb 2010)
Log Message:
-----------
Remove 'addressbookserver' package, move everything to 'calendarserver'.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/contacts-server-merge/twisted/plugins/caldav.py
    CalendarServer/branches/users/glyph/contacts-server-merge/twisted/plugins/carddav.py

Added Paths:
-----------
    CalendarServer/branches/users/glyph/contacts-server-merge/calendarserver/tap/carddav.py

Removed Paths:
-------------
    CalendarServer/branches/users/glyph/contacts-server-merge/addressbookserver/

Property Changed:
----------------
    CalendarServer/branches/users/glyph/contacts-server-merge/twistedcaldav/test/data/

Copied: CalendarServer/branches/users/glyph/contacts-server-merge/calendarserver/tap/carddav.py (from rev 5009, CalendarServer/branches/users/glyph/contacts-server-merge/addressbookserver/tap/carddav.py)
===================================================================
--- CalendarServer/branches/users/glyph/contacts-server-merge/calendarserver/tap/carddav.py	                        (rev 0)
+++ CalendarServer/branches/users/glyph/contacts-server-merge/calendarserver/tap/carddav.py	2010-02-03 04:48:30 UTC (rev 5023)
@@ -0,0 +1,103 @@
+##
+# Copyright (c) 2005-2009 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__ = [
+    "CardDAVServiceMaker",
+]
+
+import errno
+import os
+
+from zope.interface import implements
+
+from twisted.python.filepath import FilePath
+from twisted.plugin import IPlugin
+from twisted.internet.reactor import callLater
+from twisted.application.service import IServiceMaker
+
+from twistedcaldav.directory.principal import DirectoryPrincipalProvisioningResource
+
+from twistedcaldav.config import config
+from twistedcaldav.static import AddressBookHomeProvisioningFile, DirectoryBackedAddressBookFile
+from twext.log import Logger
+
+log = Logger()
+
+from calendarserver.tap.caldav import CalDAVServiceMaker
+
+try:
+    from twistedcaldav.authkerb import NegotiateCredentialFactory
+except ImportError:
+    NegotiateCredentialFactory = None
+
+from calendarserver.provision.root import RootResource
+
+
+class CardDAVServiceMaker (CalDAVServiceMaker):
+    implements(IPlugin, IServiceMaker)
+
+    tapname = "carddav"
+    description = "Darwin Contacts Server"
+
+    #
+    # Default resource classes
+    #
+    rootResourceClass            = RootResource
+    principalResourceClass       = DirectoryPrincipalProvisioningResource
+    addressBookResourceClass     = AddressBookHomeProvisioningFile
+    directoryBackedAddressBookResourceClass = DirectoryBackedAddressBookFile
+
+    def makeService_Slave(self, options):
+        result = super(CardDAVServiceMaker, self).makeService_Slave(options)
+
+        directory = self.directory
+        principalCollection = self.principalCollection
+
+        if config.EnableCardDAV:
+            log.info("Setting up address book collection: %r" % (self.addressBookResourceClass,))
+    
+            addressBookCollection = self.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" % (self.directoryBackedAddressBookResourceClass,))
+    
+                directoryBackedAddressBookCollection = self.directoryBackedAddressBookResourceClass(
+                    directoryPath,
+                    principalCollections=(principalCollection,)
+                )
+                # do this after process is owned by carddav user, not root
+                callLater(1.0, directoryBackedAddressBookCollection.provisionDirectory)
+            else:
+                # remove /directory from previous runs that may have created it
+                try:
+                    FilePath(directoryPath).remove()
+                    self.log_info("Deleted: %s" %    directoryPath)
+                except (OSError, IOError), e:
+                    if e.errno != errno.ENOENT:
+                        self.log_error("Could not delete: %s : %r" %  (directoryPath, e,))
+            root = self.root
+
+            root.putChild('addressbooks', addressBookCollection)
+            if doBacking:
+                root.putChild('directory', directoryBackedAddressBookCollection)
+        return result
+
+    makeService_Single   = makeService_Slave

Modified: CalendarServer/branches/users/glyph/contacts-server-merge/twisted/plugins/caldav.py
===================================================================
--- CalendarServer/branches/users/glyph/contacts-server-merge/twisted/plugins/caldav.py	2010-02-03 03:48:14 UTC (rev 5022)
+++ CalendarServer/branches/users/glyph/contacts-server-merge/twisted/plugins/caldav.py	2010-02-03 04:48:30 UTC (rev 5023)
@@ -1,3 +1,19 @@
+##
+# Copyright (c) 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.
+##
+
 from zope.interface import implements
 from twisted.plugin import IPlugin
 from twisted.application.service import IServiceMaker

Modified: CalendarServer/branches/users/glyph/contacts-server-merge/twisted/plugins/carddav.py
===================================================================
--- CalendarServer/branches/users/glyph/contacts-server-merge/twisted/plugins/carddav.py	2010-02-03 03:48:14 UTC (rev 5022)
+++ CalendarServer/branches/users/glyph/contacts-server-merge/twisted/plugins/carddav.py	2010-02-03 04:48:30 UTC (rev 5023)
@@ -1,36 +1,19 @@
-from zope.interface import implements
-from twisted.plugin import IPlugin
-from twisted.application.service import IServiceMaker
+##
+# Copyright (c) 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.
+##
 
-from twisted.python import reflect
+from twisted.plugins.caldav import TAP
 
-from twisted.internet.protocol import Factory
-Factory.noisy = False
-
-
-def serviceMakerProperty(propname):
-    def getProperty(self):
-        return getattr(reflect.namedClass(self.serviceMakerClass), propname)
-
-    return property(getProperty)
-
-
-class TAP(object):
-    implements(IPlugin, IServiceMaker)
-
-    def __init__(self, serviceMakerClass):
-        self.serviceMakerClass = serviceMakerClass
-        self._serviceMaker = None
-
-    options     = serviceMakerProperty("options")
-    tapname     = serviceMakerProperty("tapname")
-    description = serviceMakerProperty("description")
-
-    def makeService(self, options):
-        if self._serviceMaker is None:
-            self._serviceMaker = reflect.namedClass(self.serviceMakerClass)()
-
-        return self._serviceMaker.makeService(options)
-
-
-TwistedCardDAV = TAP("addressbookserver.tap.carddav.CardDAVServiceMaker")
+TwistedCardDAV = TAP("calendarserver.tap.carddav.CardDAVServiceMaker")


Property changes on: CalendarServer/branches/users/glyph/contacts-server-merge/twistedcaldav/test/data
___________________________________________________________________
Modified: svn:ignore
   - calendars
.calendarserver_version

   + 
calendars
.calendarserver_version
directory
addressbooks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100202/97ebfbb8/attachment-0001.html>


More information about the calendarserver-changes mailing list