[CalendarServer-changes] [10553] CalendarServer/trunk/twistedcaldav/scheduling
source_changes at macosforge.org
source_changes at macosforge.org
Sat Jan 26 09:29:10 PST 2013
Revision: 10553
http://trac.calendarserver.org//changeset/10553
Author: cdaboo at apple.com
Date: 2013-01-26 09:29:10 -0800 (Sat, 26 Jan 2013)
Log Message:
-----------
Make sure the organizer and attendee replying are never considered as part of attendee refresh processing.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/scheduling/processing.py
Added Paths:
-----------
CalendarServer/trunk/twistedcaldav/scheduling/test/test_pocessing.py
Modified: CalendarServer/trunk/twistedcaldav/scheduling/processing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/processing.py 2013-01-26 01:27:18 UTC (rev 10552)
+++ CalendarServer/trunk/twistedcaldav/scheduling/processing.py 2013-01-26 17:29:10 UTC (rev 10553)
@@ -201,6 +201,8 @@
log.debug("ImplicitProcessing - originator '%s' to recipient '%s' processing METHOD:REPLY, UID: '%s' - updating event" % (self.originator.cuaddr, self.recipient.cuaddr, self.uid))
self.organizer_calendar_resource = (yield self.writeCalendarResource(self.recipient_calendar_collection_uri, self.recipient_calendar_collection, self.recipient_calendar_name, self.recipient_calendar))
+ organizer = self.recipient_calendar.getOrganizer()
+
# Build the schedule-changes XML element
attendeeReplying, rids = processed
partstatChanged = False
@@ -232,7 +234,7 @@
# and only if the request does not indicate we should skip attendee refresh
# (e.g. inbox item processing during migration from non-implicit server)
if partstatChanged and not getattr(self.request, "noAttendeeRefresh", False):
- yield self.queueAttendeeUpdate((attendeeReplying,))
+ yield self.queueAttendeeUpdate((attendeeReplying, organizer,))
result = (True, False, True, changes,)
@@ -282,27 +284,26 @@
try:
# Get all attendees to refresh
allAttendees = sorted(list(self.recipient_calendar.getAllUniqueAttendees()))
+ allAttendees = filter(lambda x: x not in exclude_attendees, allAttendees)
- # Always need to refresh every attendee
- exclude_attendees = ()
+ if allAttendees:
+ # See if there is already a pending refresh and merge current attendees into that list,
+ # otherwise just mark all attendees as pending
+ cache = Memcacher("BatchRefreshAttendees", pickle=True)
+ pendingAttendees = yield cache.get(self.uid)
+ firstTime = False
+ if pendingAttendees:
+ for attendee in allAttendees:
+ if attendee not in pendingAttendees:
+ pendingAttendees.append(attendee)
+ else:
+ firstTime = True
+ pendingAttendees = allAttendees
+ yield cache.set(self.uid, pendingAttendees)
- # See if there is already a pending refresh and merge current attendees into that list,
- # otherwise just mark all attendees as pending
- cache = Memcacher("BatchRefreshAttendees", pickle=True)
- pendingAttendees = yield cache.get(self.uid)
- firstTime = False
- if pendingAttendees:
- for attendee in allAttendees:
- if attendee not in pendingAttendees:
- pendingAttendees.append(attendee)
- else:
- firstTime = True
- pendingAttendees = allAttendees
- yield cache.set(self.uid, pendingAttendees)
-
- # Now start the first batch off
- if firstTime:
- reactor.callLater(config.Scheduling.Options.AttendeeRefreshBatchDelaySeconds, self._doBatchRefresh)
+ # Now start the first batch off
+ if firstTime:
+ self._enqueueBatchRefresh()
finally:
yield lock.clean()
@@ -383,6 +384,13 @@
yield uidlock.clean()
+ def _enqueueBatchRefresh(self):
+ """
+ Mostly here to help unit test by being able to stub this out.
+ """
+ reactor.callLater(config.Scheduling.Options.AttendeeRefreshBatchDelaySeconds, self._doBatchRefresh)
+
+
@inlineCallbacks
def _doBatchRefresh(self):
"""
@@ -426,7 +434,7 @@
# Queue the next refresh if needed
if pendingAttendees:
- reactor.callLater(config.Scheduling.Options.AttendeeRefreshBatchIntervalSeconds, self._doBatchRefresh)
+ self._enqueueBatchRefresh()
else:
yield cache.delete(self.uid)
yield lock.release()
Added: CalendarServer/trunk/twistedcaldav/scheduling/test/test_pocessing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/test/test_pocessing.py (rev 0)
+++ CalendarServer/trunk/twistedcaldav/scheduling/test/test_pocessing.py 2013-01-26 17:29:10 UTC (rev 10553)
@@ -0,0 +1,106 @@
+##
+# Copyright (c) 2005-2013 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 twext.web2.test.test_server import SimpleRequest
+from twisted.internet.defer import inlineCallbacks
+from twistedcaldav.ical import Component
+from twistedcaldav.scheduling.processing import ImplicitProcessor
+import twistedcaldav.test.util
+from twistedcaldav.config import config
+
+class FakeImplicitProcessor(ImplicitProcessor):
+ """
+ A fake ImplicitProcessor that tracks batch refreshes.
+ """
+
+ def __init__(self):
+ self.batches = 0
+
+
+ def _enqueueBatchRefresh(self):
+ self.batches += 1
+
+
+
+class FakePrincipal(object):
+
+ def __init__(self, cuaddr):
+ self.cuaddr = cuaddr
+
+
+ def calendarUserAddresses(self):
+ return (self.cuaddr,)
+
+
+
+class BatchRefresh (twistedcaldav.test.util.TestCase):
+ """
+ iCalendar support tests
+ """
+
+ @inlineCallbacks
+ def test_queueAttendeeUpdate_no_refresh(self):
+
+ self.patch(config.Scheduling.Options, "AttendeeRefreshBatch", 5)
+
+ calendar = Component.fromString("""BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER:urn:uuid:user01
+ATTENDEE:urn:uuid:user01
+ATTENDEE:urn:uuid:user02
+END:VEVENT
+END:VCALENDAR
+""")
+ request = SimpleRequest(self.site, "PUT", "/calendar/1.ics")
+ processor = FakeImplicitProcessor()
+ processor.request = request
+ processor.uid = "12345-67890"
+ processor.recipient_calendar = calendar
+ yield processor.queueAttendeeUpdate(("urn:uuid:user02", "urn:uuid:user01",))
+ self.assertEqual(processor.batches, 0)
+
+
+ @inlineCallbacks
+ def test_queueAttendeeUpdate_with_refresh(self):
+
+ self.patch(config.Scheduling.Options, "AttendeeRefreshBatch", 5)
+
+ calendar = Component.fromString("""BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER:urn:uuid:user01
+ATTENDEE:urn:uuid:user01
+ATTENDEE:urn:uuid:user02
+ATTENDEE:urn:uuid:user03
+END:VEVENT
+END:VCALENDAR
+""")
+ request = SimpleRequest(self.site, "PUT", "/calendar/1.ics")
+ processor = FakeImplicitProcessor()
+ processor.request = request
+ processor.uid = "12345-67890"
+ processor.recipient_calendar = calendar
+ yield processor.queueAttendeeUpdate(("urn:uuid:user02", "urn:uuid:user01",))
+ self.assertEqual(processor.batches, 1)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130126/a532e986/attachment.html>
More information about the calendarserver-changes
mailing list