[CalendarServer-changes] [4579] CalendarServer/branches/users/cdaboo/partition-4464

source_changes at macosforge.org source_changes at macosforge.org
Mon Oct 12 20:03:57 PDT 2009


Revision: 4579
          http://trac.macosforge.org/projects/calendarserver/changeset/4579
Author:   cdaboo at apple.com
Date:     2009-10-12 20:03:53 -0700 (Mon, 12 Oct 2009)
Log Message:
-----------
Allow a default augment record to be set.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/partition-4464/conf/auth/augments-test.xml
    CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/augment.py
    CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/test_augment.py
    CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/test_proxyprincipalmembers.py
    CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/memcachepool.py

Added Paths:
-----------
    CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/augments-test-default.xml

Modified: CalendarServer/branches/users/cdaboo/partition-4464/conf/auth/augments-test.xml
===================================================================
--- CalendarServer/branches/users/cdaboo/partition-4464/conf/auth/augments-test.xml	2009-10-10 00:25:51 UTC (rev 4578)
+++ CalendarServer/branches/users/cdaboo/partition-4464/conf/auth/augments-test.xml	2009-10-13 03:03:53 UTC (rev 4579)
@@ -20,28 +20,11 @@
 
 <augments>
   <record>
-    <guid>admin</guid>
+    <guid>Default</guid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
-  <record>
-    <guid>apprentice</guid>
-    <enable>true</enable>
-    <enable-calendar>true</enable-calendar>
-  </record>
-  <record repeat="99">
-    <guid>user%02d</guid>
-    <enable>true</enable>
-    <enable-calendar>true</enable-calendar>
-    <cuaddr>mailto:user%02d at example.com</cuaddr>
-  </record>
   <record repeat="10">
-    <guid>public%02d</guid>
-    <enable>true</enable>
-    <enable-calendar>true</enable-calendar>
-    <cuaddr>mailto:public%02d at example.com</cuaddr>
-  </record>
-  <record repeat="10">
     <guid>location%02d</guid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>

Modified: CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/augment.py
===================================================================
--- CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/augment.py	2009-10-10 00:25:51 UTC (rev 4578)
+++ CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/augment.py	2009-10-13 03:03:53 UTC (rev 4579)
@@ -19,6 +19,7 @@
 from twistedcaldav.database import AbstractADBAPIDatabase, ADBAPISqliteMixin,\
     ADBAPIPostgreSQLMixin
 from twistedcaldav.directory.xmlaugmentsparser import XMLAugmentsParser
+import copy
 import time
 
 from twistedcaldav.log import Logger
@@ -54,8 +55,28 @@
     def __init__(self):
         pass
     
+    @inlineCallbacks
     def getAugmentRecord(self, guid):
         """
+        Get an AugmentRecord for the specified GUID or the default.
+
+        @param guid: directory GUID to lookup
+        @type guid: C{str}
+        
+        @return: L{Deferred}
+        """
+        
+        result = (yield self._lookupAugmentRecord(guid))
+        if result is None:
+            if not hasattr(self, "_defaultRecord"):
+                self._defaultRecord = (yield self._lookupAugmentRecord("Default"))
+            if self._defaultRecord is not None:
+                result = copy.deepcopy(self._defaultRecord)
+                result.guid = guid
+        returnValue(result)
+
+    def _lookupAugmentRecord(self, guid):
+        """
         Get an AugmentRecord for the specified GUID.
 
         @param guid: directory GUID to lookup
@@ -95,7 +116,7 @@
             
         self.lastCached = time.time()
 
-    def getAugmentRecord(self, guid):
+    def _lookupAugmentRecord(self, guid):
         """
         Get an AugmentRecord for the specified GUID.
 
@@ -148,7 +169,7 @@
         AbstractADBAPIDatabase.__init__(self, dbID, dbapiName, dbapiArgs, True, **kwargs)
         
     @inlineCallbacks
-    def getAugmentRecord(self, guid):
+    def _lookupAugmentRecord(self, guid):
         """
         Get an AugmentRecord for the specified GUID.
 

Added: CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/augments-test-default.xml
===================================================================
--- CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/augments-test-default.xml	                        (rev 0)
+++ CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/augments-test-default.xml	2009-10-13 03:03:53 UTC (rev 4579)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+Copyright (c) 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.
+ -->
+
+<!DOCTYPE accounts SYSTEM "../../../conf/auth/augments.dtd">
+
+<augments>
+  <record>
+    <guid>Default</guid>
+    <enable>true</enable>
+    <enable-calendar>true</enable-calendar>
+    <hosted-at>00001</hosted-at>
+  </record>
+  <record>
+    <guid>D11F03A0-97EA-48AF-9A6C-FAC7F3975766</guid>
+    <enable>true</enable>
+  </record>
+  <record>
+    <guid>6423F94A-6B76-4A3A-815B-D52CFD77935D</guid>
+    <enable>true</enable>
+    <enable-calendar>true</enable-calendar>
+    <cuaddr>mailto:wsanchez at example.com</cuaddr>
+  </record>
+  <record>
+    <guid>5A985493-EE2C-4665-94CF-4DFEA3A89500</guid>
+    <enable>false</enable>
+  </record>
+  <record>
+    <guid>8B4288F6-CC82-491D-8EF9-642EF4F3E7D0</guid>
+    <enable>true</enable>
+    <enable-calendar>false</enable-calendar>
+  </record>
+  <record>
+    <guid>5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1</guid>
+    <enable>true</enable>
+    <hosted-at>00001</hosted-at>
+  </record>
+  <record>
+    <guid>543D28BA-F74F-4D5F-9243-B3E3A61171E5</guid>
+    <enable>true</enable>
+    <hosted-at>00002</hosted-at>
+  </record>
+  <record>
+    <guid>6A73326A-F781-47E7-A9F8-AF47364D4152</guid>
+    <enable>true</enable>
+    <hosted-at>00002</hosted-at>
+    <enable>true</enable>
+    <enable-calendar>true</enable-calendar>
+    <auto-schedule>true</auto-schedule>
+    <cuaddr>mailto:usera at example.com</cuaddr>
+    <cuaddr>mailto:user.a at example.com</cuaddr>
+    <cuaddr>mailto:user_a at example.com</cuaddr>
+  </record>
+</augments>

Modified: CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/test_augment.py
===================================================================
--- CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/test_augment.py	2009-10-10 00:25:51 UTC (rev 4578)
+++ CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/test_augment.py	2009-10-13 03:03:53 UTC (rev 4579)
@@ -23,6 +23,7 @@
 import os
 
 xmlFile = os.path.join(os.path.dirname(__file__), "augments-test.xml")
+xmlFileDefault = os.path.join(os.path.dirname(__file__), "augments-test-default.xml")
 
 testRecords = (
     {"guid":"D11F03A0-97EA-48AF-9A6C-FAC7F3975766", "enabled":True,  "hostedAt":"", "enabledForCalendaring":False, "autoSchedule":False, "calendarUserAddresses":set()},
@@ -34,6 +35,8 @@
     {"guid":"6A73326A-F781-47E7-A9F8-AF47364D4152", "enabled":True,  "hostedAt":"00002", "enabledForCalendaring":True, "autoSchedule":True, "calendarUserAddresses":set(("mailto:usera at example.com", "mailto:user.a at example.com", "mailto:user_a at example.com",))},
 )
 
+testRecordDefault = {"guid":"A4318887-F2C7-4A70-9056-B88CC8DB26F1", "enabled":True,  "hostedAt":"00001", "enabledForCalendaring":True, "autoSchedule":False, "calendarUserAddresses":set()}
+
 class AugmentTests(TestCase):
 
     @inlineCallbacks
@@ -63,6 +66,16 @@
 
         yield self._checkNoRecord(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
 
+    @inlineCallbacks
+    def test_read_default(self):
+        
+        db = AugmentXMLDB((xmlFileDefault,))
+
+        for item in testRecords:
+            yield self._checkRecord(db, item)
+
+        yield self._checkRecord(db, testRecordDefault)
+
     def test_parseErrors(self):
         
         db = {}
@@ -108,6 +121,20 @@
 
         yield self._checkNoRecord(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
 
+    @inlineCallbacks
+    def test_read_default(self):
+        
+        db = AugmentSqliteDB(self.mktemp())
+
+        dbxml = AugmentXMLDB((xmlFileDefault,))
+        for record in dbxml.db.values():
+            yield db.addAugmentRecord(record)
+
+        for item in testRecords:
+            yield self._checkRecord(db, item)
+
+        yield self._checkRecord(db, testRecordDefault)
+
 class AugmentPostgreSQLTests(AugmentTests):
 
     @inlineCallbacks
@@ -125,6 +152,21 @@
 
         yield self._checkNoRecord(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
 
+    @inlineCallbacks
+    def test_read_default(self):
+        
+        db = AugmentPostgreSQLDB("localhost", "augments")
+        yield db.clean()
+
+        dbxml = AugmentXMLDB((xmlFileDefault,))
+        for record in dbxml.db.values():
+            yield db.addAugmentRecord(record)
+
+        for item in testRecords:
+            yield self._checkRecord(db, item)
+
+        yield self._checkRecord(db, testRecordDefault)
+
 try:
     import pgdb
 except ImportError:

Modified: CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/test_proxyprincipalmembers.py
===================================================================
--- CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/test_proxyprincipalmembers.py	2009-10-10 00:25:51 UTC (rev 4578)
+++ CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/test_proxyprincipalmembers.py	2009-10-13 03:03:53 UTC (rev 4579)
@@ -303,7 +303,7 @@
         oldCacheNotifier = DirectoryPrincipalResource.cacheNotifierFactory
 
         try:
-            DirectoryPrincipalResource.cacheNotifierFactory = (lambda _1, _2: notifier)
+            DirectoryPrincipalResource.cacheNotifierFactory = (lambda _1, _2, **kwargs: notifier)
 
             self.assertEquals(notifier.changedCount, 0)
 

Modified: CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/memcachepool.py
===================================================================
--- CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/memcachepool.py	2009-10-10 00:25:51 UTC (rev 4578)
+++ CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/memcachepool.py	2009-10-13 03:03:53 UTC (rev 4579)
@@ -411,4 +411,6 @@
         _memCachePoolHandler[handle] = pool
 
 def defaultCachePool(name):
+    if name not in _memCachePoolHandler:
+        name = "Default"
     return _memCachePoolHandler[name]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20091012/7b13d7ae/attachment-0001.html>


More information about the calendarserver-changes mailing list