[CalendarServer-changes] [351] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Nov 2 10:56:45 PST 2006


Revision: 351
          http://trac.macosforge.org/projects/calendarserver/changeset/351
Author:   cdaboo at apple.com
Date:     2006-11-02 10:56:45 -0800 (Thu, 02 Nov 2006)

Log Message:
-----------
Fix for repository builder with proxies and directory. Also, changed the builder so there is no need to have explicit
principal property set property.

Modified Paths:
--------------
    CalendarServer/trunk/conf/repository-proxy.xml
    CalendarServer/trunk/conf/repository-static.xml
    CalendarServer/trunk/conf/repository.dtd
    CalendarServer/trunk/conf/repository.xml
    CalendarServer/trunk/twistedcaldav/repository.py

Modified: CalendarServer/trunk/conf/repository-proxy.xml
===================================================================
--- CalendarServer/trunk/conf/repository-proxy.xml	2006-11-02 16:45:35 UTC (rev 350)
+++ CalendarServer/trunk/conf/repository-proxy.xml	2006-11-02 18:56:45 UTC (rev 351)
@@ -20,7 +20,7 @@
 
 <repository>
 
-  <docroot auto-principal-collection-set="no">
+  <docroot auto-principal-collection-set="yes">
     <collection>
       <pytype>twisted.web2.dav.static.DAVFile</pytype>
       <properties>
@@ -37,13 +37,6 @@
             <inheritable/>
           </ace>
         </acl>
-        <!--
-          Must explicitly set which principal hierarchies will be
-          listed in WebDAV properties.  The order of these will
-          determine how a user id will map to a principal in a
-          particular hierarchy if an id appears in more than one.
-         -->
-        <prop><principal-collection-set xmlns="DAV:"><href>/principals/localusers/</href><href>/principals/users/</href><href>/principals/users/</href><href>/principals/groups/</href><href>/principals/resources/</href></principal-collection-set></prop>
       </properties>
       <members>
         <!--
@@ -124,7 +117,7 @@
             </collection>
           </members>
         </collection>
-        <collection name="principals">
+        <collection name="principals" initialize="yes">
           <pytype>twistedcaldav.directory.DirectoryPrincipalProvisioningResource</pytype>
           <params>
             <param>
@@ -142,7 +135,7 @@
             </acl>
           </properties>
           <members>
-            <collection name="users">
+            <collection name="users" tag="principals">
               <pytype>twistedcaldav.directory.DirectoryUserPrincipalProvisioningResource</pytype>
               <properties>
                 <acl>
@@ -155,7 +148,7 @@
               </properties>
               <members/>
             </collection>
-            <collection name="groups">
+            <collection name="groups" tag="principals">
               <pytype>twistedcaldav.directory.DirectoryGroupPrincipalProvisioningResource</pytype>
               <properties>
                 <acl>
@@ -168,7 +161,7 @@
               </properties>
               <members/>
             </collection>
-            <collection name="resources">
+            <collection name="resources" tag="principals">
               <pytype>twistedcaldav.directory.DirectoryResourcePrincipalProvisioningResource</pytype>
               <properties>
                 <acl>
@@ -181,7 +174,7 @@
               </properties>
               <members/>
             </collection>
-            <collection name="localusers" tag="principals">
+            <collection name="localusers" tag="principals" account="yes">
               <pytype>twistedcaldav.static.CalendarPrincipalCollectionFile</pytype>
                 <properties>
                   <acl>

Modified: CalendarServer/trunk/conf/repository-static.xml
===================================================================
--- CalendarServer/trunk/conf/repository-static.xml	2006-11-02 16:45:35 UTC (rev 350)
+++ CalendarServer/trunk/conf/repository-static.xml	2006-11-02 18:56:45 UTC (rev 351)
@@ -51,7 +51,7 @@
             </acl>
           </properties>
           <members>
-            <collection name="users" tag="principals">
+            <collection name="users" tag="principals" account="yes">
               <pytype>twistedcaldav.static.CalendarPrincipalCollectionFile</pytype>
               <properties>
                 <acl>

Modified: CalendarServer/trunk/conf/repository.dtd
===================================================================
--- CalendarServer/trunk/conf/repository.dtd	2006-11-02 16:45:35 UTC (rev 350)
+++ CalendarServer/trunk/conf/repository.dtd	2006-11-02 18:56:45 UTC (rev 351)
@@ -23,7 +23,9 @@
 
     <!ELEMENT collection (pytype?, params?, properties, members)>
       <!ATTLIST collection name CDATA ""
-                             tag (none|principals|calendars) "none">
+                             tag (none|principals|calendars) "none"
+                             account (yes|no) "no"
+                             initialize (yes|no) "no">
       <!ELEMENT pytype     (#PCDATA)>
       <!ELEMENT params     (param*)>
         <!ELEMENT param    (key, value)>

Modified: CalendarServer/trunk/conf/repository.xml
===================================================================
--- CalendarServer/trunk/conf/repository.xml	2006-11-02 16:45:35 UTC (rev 350)
+++ CalendarServer/trunk/conf/repository.xml	2006-11-02 18:56:45 UTC (rev 351)
@@ -20,7 +20,7 @@
 
 <repository>
 
-  <docroot auto-principal-collection-set="no">
+  <docroot auto-principal-collection-set="yes">
     <collection>
       <pytype>twisted.web2.dav.static.DAVFile</pytype>
       <properties>
@@ -37,13 +37,6 @@
             <inheritable/>
           </ace>
         </acl>
-        <!--
-          Must explicitly set which principal hierarchies will be
-          listed in WebDAV properties.  The order of these will
-          determine how a user id will map to a principal in a
-          particular hierarchy if an id appears in more than one.
-         -->
-        <prop><principal-collection-set xmlns="DAV:"><href>/principals/users/</href><href>/principals/groups/</href><href>/principals/resources/</href></principal-collection-set></prop>
       </properties>
       <members>
         <!--
@@ -124,7 +117,7 @@
             </collection>
           </members>
         </collection>
-        <collection name="principals" tag="principals">
+        <collection name="principals" initialize="yes">
           <pytype>twistedcaldav.directory.DirectoryPrincipalProvisioningResource</pytype>
           <params>
             <param>
@@ -142,7 +135,7 @@
             </acl>
           </properties>
           <members>
-            <collection name="users">
+            <collection name="users" tag="principals">
               <pytype>twistedcaldav.directory.DirectoryUserPrincipalProvisioningResource</pytype>
               <properties>
                 <acl>
@@ -155,7 +148,7 @@
               </properties>
               <members/>
             </collection>
-            <collection name="groups">
+            <collection name="groups" tag="principals">
               <pytype>twistedcaldav.directory.DirectoryGroupPrincipalProvisioningResource</pytype>
               <properties>
                 <acl>
@@ -168,7 +161,7 @@
               </properties>
               <members/>
             </collection>
-            <collection name="resources">
+            <collection name="resources" tag="principals">
               <pytype>twistedcaldav.directory.DirectoryResourcePrincipalProvisioningResource</pytype>
               <properties>
                 <acl>

Modified: CalendarServer/trunk/twistedcaldav/repository.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/repository.py	2006-11-02 16:45:35 UTC (rev 350)
+++ CalendarServer/trunk/twistedcaldav/repository.py	2006-11-02 18:56:45 UTC (rev 351)
@@ -88,6 +88,8 @@
 
 ATTRIBUTE_NAME = "name"
 ATTRIBUTE_TAG = "tag"
+ATTRIBUTE_ACCOUNT = "account"
+ATTRIBUTE_INITIALIZE = "initialize"
 
 ATTRVALUE_NONE = "none"
 ATTRVALUE_PRINCIPALS = "principals"
@@ -293,7 +295,12 @@
         
         self.docRoot.build()
         if self.doAccounts:
-            self.accounts.provision(self.docRoot.principalCollection, self.docRoot.calendarHome, self.resetACLs)
+            self.accounts.provision(
+                self.docRoot.principalCollections,
+                self.docRoot.accountCollection,
+                self.docRoot.initCollections,
+                self.docRoot.calendarHome,
+                self.resetACLs)
             
         # Handle global quota value
         CalendarHomeFile.quotaLimit = self.quota
@@ -322,7 +329,9 @@
         """
         self.collection = None
         self.path = docroot
-        self.principalCollection = None
+        self.principalCollections = []
+        self.accountCollection = None
+        self.initCollections = []
         self.calendarHome = None
         self.autoPrincipalCollectionSet = True
         
@@ -349,12 +358,15 @@
         # Setup the principal-collection-set property if required
         if self.autoPrincipalCollectionSet:
             # Check that a principal collection was actually created and 'tagged'
-            if self.principalCollection is None:
+            if not self.principalCollections:
                 log.msg("Cannot create a DAV:principal-collection-set property on the root resource because there are no principal collections.")
                 return
             
             # Create the private property
-            pcs = davxml.PrincipalCollectionSet(davxml.HRef.fromString(self.principalCollection.uri))
+            hrefs = []
+            for collection in self.principalCollections:
+                hrefs.append(davxml.HRef.fromString(collection.uri))
+            pcs = davxml.PrincipalCollectionSet(*hrefs)
             self.collection.resource.writeDeadProperty(pcs)
 
 class Collection (object):
@@ -382,9 +394,13 @@
         if node.hasAttribute(ATTRIBUTE_TAG):
             tag = node.getAttribute(ATTRIBUTE_TAG)
             if tag == ATTRVALUE_PRINCIPALS:
-                builder.principalCollection = self
+                builder.principalCollections.append(self)
             elif tag == ATTRVALUE_CALENDARS:
                 builder.calendarHome = self
+        if node.hasAttribute(ATTRIBUTE_ACCOUNT) and node.getAttribute(ATTRIBUTE_ACCOUNT) == ATTRIBUTE_VALUE_YES:
+            builder.accountCollection = self
+        if node.hasAttribute(ATTRIBUTE_INITIALIZE) and node.getAttribute(ATTRIBUTE_INITIALIZE) == ATTRIBUTE_VALUE_YES:
+            builder.initCollections.append(self)
         
         for child in node._get_childNodes():
             if child._get_localName() == ELEMENT_PYTYPE:
@@ -635,7 +651,9 @@
 
     def __init__(self):
         self.items = []
-        self.principalCollection = None
+        self.principalCollections = None
+        self.accountCollection = None
+        self.initCollections = None
         self.calendarHome = None
         
     def parseXML( self, node ):
@@ -654,24 +672,34 @@
                 principal.parseXML( child )
                 self.items.append((repeat, principal))
     
-    def provision(self, principalCollection, calendarHome, resetACLs):
+    def provision(self, principalCollections, accountCollection, initCollections, calendarHome, resetACLs):
         """
         Carry out provisioning operation.
-        @param principalCollection: the L{Collection} of the principal collection in which to
+        @param principalCollections: a C{list} of L{Collection}'s for the principal collections.
+        @param accountCollection: the L{Collection} of the principal collection in which to
             create user principals.
-        @param calendarHome:        the L{Collection} for the calendar home of principals.
-        @param resetACLs:           if True, ACL privileges on all resources related to the
+        @param initCollections: a C{list} of L{Collection}'s for the principal collections to be initialized.
+        @param calendarHome:  the L{Collection} for the calendar home of principals.
+        @param resetACLs: if True, ACL privileges on all resources related to the
             accounts being created are reset, if False no ACL privileges are changed.
         """
-        self.principalCollection = principalCollection
+        self.principalCollections = principalCollections
+        self.accountCollection = accountCollection
+        self.initCollections = initCollections
         self.calendarHome = calendarHome
 
-        if self.calendarHome is not None:
-            self.principalCollection.resource.initialize(
-                self.calendarHome.uri,
-                self.calendarHome.resource,
-            )
+        if self.initCollections and self.calendarHome is not None:
+            for collection in self.initCollections:
+                collection.resource.initialize(
+                    self.calendarHome.uri,
+                    self.calendarHome.resource,
+                )
 
+        # Check for proper account home
+        if not self.accountCollection:
+            log.err("Accounts cannot be created: no principal collection was marked with an account attribute.")
+            raise ValueError, "Accounts cannot be created."
+
         # Provision each user
         for repeat, principal in self.items:
             if repeat == 1:
@@ -687,10 +715,10 @@
         @param resetACLs: if True, ACL privileges on all resources related to the
             accounts being created are reset, if False no ACL privileges are changed.
         """
-        principalURL = joinURL(self.principalCollection.uri, item.uid)
+        principalURL = joinURL(self.accountCollection.uri, item.uid)
 
         # Create principal resource
-        principal = FilePath(os.path.join(self.principalCollection.resource.fp.path, item.uid))
+        principal = FilePath(os.path.join(self.accountCollection.resource.fp.path, item.uid))
         principal_exists = principal.exists()
         if not principal_exists:
             principal.open("w").close()

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061102/f314281b/attachment.html


More information about the calendarserver-changes mailing list