<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[4579] CalendarServer/branches/users/cdaboo/partition-4464</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.macosforge.org/projects/calendarserver/changeset/4579">4579</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2009-10-12 20:03:53 -0700 (Mon, 12 Oct 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Allow a default augment record to be set.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboopartition4464confauthaugmentstestxml">CalendarServer/branches/users/cdaboo/partition-4464/conf/auth/augments-test.xml</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopartition4464twistedcaldavdirectoryaugmentpy">CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/augment.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopartition4464twistedcaldavdirectorytesttest_augmentpy">CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/test_augment.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopartition4464twistedcaldavdirectorytesttest_proxyprincipalmemberspy">CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/test_proxyprincipalmembers.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopartition4464twistedcaldavmemcachepoolpy">CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/memcachepool.py</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboopartition4464twistedcaldavdirectorytestaugmentstestdefaultxml">CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/augments-test-default.xml</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserscdaboopartition4464confauthaugmentstestxml"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/partition-4464/conf/auth/augments-test.xml (4578 => 4579)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -20,28 +20,11 @@
</span><span class="cx">
</span><span class="cx"> <augments>
</span><span class="cx"> <record>
</span><del>- <guid>admin</guid>
</del><ins>+ <guid>Default</guid>
</ins><span class="cx"> <enable>true</enable>
</span><span class="cx"> <enable-calendar>true</enable-calendar>
</span><span class="cx"> </record>
</span><del>- <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@example.com</cuaddr>
- </record>
</del><span class="cx"> <record repeat="10">
</span><del>- <guid>public%02d</guid>
- <enable>true</enable>
- <enable-calendar>true</enable-calendar>
- <cuaddr>mailto:public%02d@example.com</cuaddr>
- </record>
- <record repeat="10">
</del><span class="cx"> <guid>location%02d</guid>
</span><span class="cx"> <enable>true</enable>
</span><span class="cx"> <enable-calendar>true</enable-calendar>
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopartition4464twistedcaldavdirectoryaugmentpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/augment.py (4578 => 4579)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -19,6 +19,7 @@
</span><span class="cx"> from twistedcaldav.database import AbstractADBAPIDatabase, ADBAPISqliteMixin,\
</span><span class="cx"> ADBAPIPostgreSQLMixin
</span><span class="cx"> from twistedcaldav.directory.xmlaugmentsparser import XMLAugmentsParser
</span><ins>+import copy
</ins><span class="cx"> import time
</span><span class="cx">
</span><span class="cx"> from twistedcaldav.log import Logger
</span><span class="lines">@@ -54,8 +55,28 @@
</span><span class="cx"> def __init__(self):
</span><span class="cx"> pass
</span><span class="cx">
</span><ins>+ @inlineCallbacks
</ins><span class="cx"> def getAugmentRecord(self, guid):
</span><span class="cx"> """
</span><ins>+ 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):
+ """
</ins><span class="cx"> Get an AugmentRecord for the specified GUID.
</span><span class="cx">
</span><span class="cx"> @param guid: directory GUID to lookup
</span><span class="lines">@@ -95,7 +116,7 @@
</span><span class="cx">
</span><span class="cx"> self.lastCached = time.time()
</span><span class="cx">
</span><del>- def getAugmentRecord(self, guid):
</del><ins>+ def _lookupAugmentRecord(self, guid):
</ins><span class="cx"> """
</span><span class="cx"> Get an AugmentRecord for the specified GUID.
</span><span class="cx">
</span><span class="lines">@@ -148,7 +169,7 @@
</span><span class="cx"> AbstractADBAPIDatabase.__init__(self, dbID, dbapiName, dbapiArgs, True, **kwargs)
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def getAugmentRecord(self, guid):
</del><ins>+ def _lookupAugmentRecord(self, guid):
</ins><span class="cx"> """
</span><span class="cx"> Get an AugmentRecord for the specified GUID.
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopartition4464twistedcaldavdirectorytestaugmentstestdefaultxml"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/augments-test-default.xml (0 => 4579)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,68 @@
</span><ins>+<?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@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@example.com</cuaddr>
+ <cuaddr>mailto:user.a@example.com</cuaddr>
+ <cuaddr>mailto:user_a@example.com</cuaddr>
+ </record>
+</augments>
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopartition4464twistedcaldavdirectorytesttest_augmentpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/test_augment.py (4578 => 4579)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -23,6 +23,7 @@
</span><span class="cx"> import os
</span><span class="cx">
</span><span class="cx"> xmlFile = os.path.join(os.path.dirname(__file__), "augments-test.xml")
</span><ins>+xmlFileDefault = os.path.join(os.path.dirname(__file__), "augments-test-default.xml")
</ins><span class="cx">
</span><span class="cx"> testRecords = (
</span><span class="cx"> {"guid":"D11F03A0-97EA-48AF-9A6C-FAC7F3975766", "enabled":True, "hostedAt":"", "enabledForCalendaring":False, "autoSchedule":False, "calendarUserAddresses":set()},
</span><span class="lines">@@ -34,6 +35,8 @@
</span><span class="cx"> {"guid":"6A73326A-F781-47E7-A9F8-AF47364D4152", "enabled":True, "hostedAt":"00002", "enabledForCalendaring":True, "autoSchedule":True, "calendarUserAddresses":set(("mailto:usera@example.com", "mailto:user.a@example.com", "mailto:user_a@example.com",))},
</span><span class="cx"> )
</span><span class="cx">
</span><ins>+testRecordDefault = {"guid":"A4318887-F2C7-4A70-9056-B88CC8DB26F1", "enabled":True, "hostedAt":"00001", "enabledForCalendaring":True, "autoSchedule":False, "calendarUserAddresses":set()}
+
</ins><span class="cx"> class AugmentTests(TestCase):
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -63,6 +66,16 @@
</span><span class="cx">
</span><span class="cx"> yield self._checkNoRecord(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
</span><span class="cx">
</span><ins>+ @inlineCallbacks
+ def test_read_default(self):
+
+ db = AugmentXMLDB((xmlFileDefault,))
+
+ for item in testRecords:
+ yield self._checkRecord(db, item)
+
+ yield self._checkRecord(db, testRecordDefault)
+
</ins><span class="cx"> def test_parseErrors(self):
</span><span class="cx">
</span><span class="cx"> db = {}
</span><span class="lines">@@ -108,6 +121,20 @@
</span><span class="cx">
</span><span class="cx"> yield self._checkNoRecord(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
</span><span class="cx">
</span><ins>+ @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)
+
</ins><span class="cx"> class AugmentPostgreSQLTests(AugmentTests):
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -125,6 +152,21 @@
</span><span class="cx">
</span><span class="cx"> yield self._checkNoRecord(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
</span><span class="cx">
</span><ins>+ @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)
+
</ins><span class="cx"> try:
</span><span class="cx"> import pgdb
</span><span class="cx"> except ImportError:
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopartition4464twistedcaldavdirectorytesttest_proxyprincipalmemberspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/directory/test/test_proxyprincipalmembers.py (4578 => 4579)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -303,7 +303,7 @@
</span><span class="cx"> oldCacheNotifier = DirectoryPrincipalResource.cacheNotifierFactory
</span><span class="cx">
</span><span class="cx"> try:
</span><del>- DirectoryPrincipalResource.cacheNotifierFactory = (lambda _1, _2: notifier)
</del><ins>+ DirectoryPrincipalResource.cacheNotifierFactory = (lambda _1, _2, **kwargs: notifier)
</ins><span class="cx">
</span><span class="cx"> self.assertEquals(notifier.changedCount, 0)
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopartition4464twistedcaldavmemcachepoolpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/partition-4464/twistedcaldav/memcachepool.py (4578 => 4579)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -411,4 +411,6 @@
</span><span class="cx"> _memCachePoolHandler[handle] = pool
</span><span class="cx">
</span><span class="cx"> def defaultCachePool(name):
</span><ins>+ if name not in _memCachePoolHandler:
+ name = "Default"
</ins><span class="cx"> return _memCachePoolHandler[name]
</span></span></pre>
</div>
</div>
</body>
</html>