[CalendarServer-changes] [7865] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Wed Aug 10 14:24:54 PDT 2011
Revision: 7865
http://trac.macosforge.org/projects/calendarserver/changeset/7865
Author: cdaboo at apple.com
Date: 2011-08-10 14:24:51 -0700 (Wed, 10 Aug 2011)
Log Message:
-----------
Make sure partition id in augments is properly ignored if the associated server is not actually partitioned.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/directory.py
CalendarServer/trunk/twistedcaldav/directory/principal.py
CalendarServer/trunk/twistedcaldav/servers.py
CalendarServer/trunk/twistedcaldav/test/test_servers.py
Modified: CalendarServer/trunk/twistedcaldav/directory/directory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/directory.py 2011-08-10 20:09:01 UTC (rev 7864)
+++ CalendarServer/trunk/twistedcaldav/directory/directory.py 2011-08-10 21:24:51 UTC (rev 7865)
@@ -1145,9 +1145,19 @@
if config.Servers.Enabled and self.serverID:
s = servers.Servers.getServerById(self.serverID)
if s:
- return s.thisServer and (not self.partitionID or self.partitionID == config.ServerPartitionID)
+ return s.thisServer and (not s.isPartitioned() or not self.partitionID or self.partitionID == config.ServerPartitionID)
return True
+ def effectivePartitionID(self):
+ """
+ Record partition ID taking into account whether the server is partitioned.
+ """
+ if config.Servers.Enabled and self.serverID:
+ s = servers.Servers.getServerById(self.serverID)
+ if s and s.isPartitioned():
+ return self.partitionID
+ return ""
+
def thisServer(self):
if config.Servers.Enabled and self.serverID:
s = servers.Servers.getServerById(self.serverID)
Modified: CalendarServer/trunk/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/principal.py 2011-08-10 20:09:01 UTC (rev 7864)
+++ CalendarServer/trunk/twistedcaldav/directory/principal.py 2011-08-10 21:24:51 UTC (rev 7865)
@@ -601,7 +601,7 @@
"""Directory GUID: %s\n""" % (self.record.service.guid,),
"""Realm: %s\n""" % (self.record.service.realmName,),
"""Hosted-At: %s\n""" % (self.record.serverURI(),) if config.Servers.Enabled else "",
- """Partition: %s\n""" % (self.record.partitionID,) if config.Servers.Enabled and self.record.partitionID else "",
+ """Partition: %s\n""" % (self.record.effectivePartitionID(),) if config.Servers.Enabled else "",
"""\n"""
"""Principal Information\n"""
"""---------------------\n"""
Modified: CalendarServer/trunk/twistedcaldav/servers.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/servers.py 2011-08-10 20:09:01 UTC (rev 7864)
+++ CalendarServer/trunk/twistedcaldav/servers.py 2011-08-10 21:24:51 UTC (rev 7865)
@@ -199,6 +199,9 @@
def getPartitionURIForId(self, id):
return self.partitions.get(id)
+ def isPartitioned(self):
+ return len(self.partitions) != 0
+
def installReverseProxies(self, ownUID, maxClients):
for partition, url in self.partitions.iteritems():
Modified: CalendarServer/trunk/twistedcaldav/test/test_servers.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_servers.py 2011-08-10 20:09:01 UTC (rev 7864)
+++ CalendarServer/trunk/twistedcaldav/test/test_servers.py 2011-08-10 21:24:51 UTC (rev 7865)
@@ -122,6 +122,13 @@
self.assertFalse(servers.getServerById("00001").thisServer)
self.assertTrue(servers.getServerById("00002").thisServer)
+ def test_check_is_partitioned(self):
+
+ servers = self._setupServers()
+
+ self.assertFalse(servers.getServerById("00001").isPartitioned())
+ self.assertTrue(servers.getServerById("00002").isPartitioned())
+
def test_check_this_ip(self):
servers = self._setupServers()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110810/cea3ec10/attachment.html>
More information about the calendarserver-changes
mailing list