<!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>[13940] CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling</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.calendarserver.org//changeset/13940">13940</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-09-04 13:14:20 -0700 (Thu, 04 Sep 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Additional debug logging for auto-accept processing.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtxdavcaldavdatastoreschedulingfreebusypy">CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/freebusy.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtxdavcaldavdatastoreschedulingprocessingpy">CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/processing.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesreleaseCalendarServer53devtxdavcaldavdatastoreschedulingfreebusypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/freebusy.py (13939 => 13940)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/freebusy.py        2014-09-03 18:36:05 UTC (rev 13939)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/freebusy.py        2014-09-04 20:14:20 UTC (rev 13940)
</span><span class="lines">@@ -106,6 +106,7 @@
</span><span class="cx"> event_details=None,
</span><span class="cx"> logItems=None,
</span><span class="cx"> accountingItems=None,
</span><ins>+ allowCache=True,
</ins><span class="cx"> ):
</span><span class="cx"> """
</span><span class="cx"> Run a free busy report on the specified calendar collection
</span><span class="lines">@@ -127,6 +128,7 @@
</span><span class="cx"> @param event_details: a C{list} into which to store extended VEVENT details if not C{None}
</span><span class="cx"> @param logItems: a C{dict} to store logging info to
</span><span class="cx"> @param accountingItems: a C{dict} to store accounting info to
</span><ins>+ @param allowCache: if C{True} the FB cache will be used, otherwise it will never be used
</ins><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> # First check the privilege on this collection
</span><span class="lines">@@ -178,12 +180,12 @@
</span><span class="cx"> rich_options["resource"] = True
</span><span class="cx">
</span><span class="cx"> # Try cache
</span><del>- resources = (yield FBCacheEntry.getCacheEntry(calresource, attendee_uid, timerange)) if config.EnableFreeBusyCache else None
</del><ins>+ resources = (yield FBCacheEntry.getCacheEntry(calresource, attendee_uid, timerange)) if config.EnableFreeBusyCache and allowCache else None
</ins><span class="cx">
</span><span class="cx"> if resources is None:
</span><span class="cx">
</span><span class="cx"> if accountingItems is not None:
</span><del>- accountingItems["fb-uncached"] = accountingItems.get("fb-uncached", 0) + 1
</del><ins>+ accountingItems["fb-cached"] = False
</ins><span class="cx">
</span><span class="cx"> caching = False
</span><span class="cx"> if config.EnableFreeBusyCache:
</span><span class="lines">@@ -233,7 +235,7 @@
</span><span class="cx">
</span><span class="cx"> else:
</span><span class="cx"> if accountingItems is not None:
</span><del>- accountingItems["fb-cached"] = accountingItems.get("fb-cached", 0) + 1
</del><ins>+ accountingItems["fb-cached"] = True
</ins><span class="cx">
</span><span class="cx"> # Log extended item
</span><span class="cx"> if logItems is not None:
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtxdavcaldavdatastoreschedulingprocessingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/processing.py (13939 => 13940)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/processing.py        2014-09-03 18:36:05 UTC (rev 13939)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/processing.py        2014-09-04 20:14:20 UTC (rev 13940)
</span><span class="lines">@@ -555,7 +555,7 @@
</span><span class="cx"> self.recipient.principal,
</span><span class="cx"> json.dumps(accounting) + "\r\n",
</span><span class="cx"> filename=self.uid.encode("base64")[:-1] + ".txt"
</span><del>- )
</del><ins>+ )
</ins><span class="cx">
</span><span class="cx"> # Only store inbox item when reply is not sent or always for users
</span><span class="cx"> store_inbox = store_inbox or self.recipient.principal.getCUType() == "INDIVIDUAL"
</span><span class="lines">@@ -676,11 +676,10 @@
</span><span class="cx"> processed_message, delete_original, rids = iTipProcessing.processCancel(self.message, self.recipient_calendar, autoprocessing=autoprocessed)
</span><span class="cx"> if processed_message:
</span><span class="cx"> if autoprocessed and accountingEnabled("AutoScheduling", self.recipient.principal):
</span><del>- accounting = {
- "action": "cancel",
- "when": PyCalendarDateTime.getNowUTC().getText(),
- "deleting": delete_original,
- }
</del><ins>+ accounting = collections.OrderedDict()
+ accounting["when"] = PyCalendarDateTime.getNowUTC().getText()
+ accounting["deleting"] = delete_original
+ accounting["action"] = "cancel"
</ins><span class="cx"> emitAccounting(
</span><span class="cx"> "AutoScheduling",
</span><span class="cx"> self.recipient.principal,
</span><span class="lines">@@ -807,11 +806,10 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> if accountingEnabled("AutoScheduling", self.recipient.principal):
</span><del>- accounting = {
- "when": PyCalendarDateTime.getNowUTC().getText(),
- "automode": automode,
- "changed": False,
- }
</del><ins>+ accounting = collections.OrderedDict()
+ accounting["when"] = PyCalendarDateTime.getNowUTC().getText()
+ accounting["automode"] = automode
+ accounting["changed"] = False
</ins><span class="cx"> else:
</span><span class="cx"> accounting = None
</span><span class="cx">
</span><span class="lines">@@ -869,7 +867,6 @@
</span><span class="cx"> fbset = [fbcalendar for fbcalendar in fbset if fbcalendar.isUsedForFreeBusy()]
</span><span class="cx"> if accounting is not None:
</span><span class="cx"> accounting["fbset"] = [testcal.name() for testcal in fbset]
</span><del>- accounting["tr"] = []
</del><span class="cx">
</span><span class="cx"> for testcal in fbset:
</span><span class="cx">
</span><span class="lines">@@ -878,6 +875,10 @@
</span><span class="cx"> tz = testcal.getTimezone()
</span><span class="cx"> tzinfo = tz.gettimezone() if tz is not None else PyCalendarTimezone(utc=True)
</span><span class="cx">
</span><ins>+ if accounting is not None:
+ accounting[testcal.name()] = {}
+ accounting[testcal.name()]["tr"] = []
+
</ins><span class="cx"> # Now do search for overlapping time-range and set instance.free based
</span><span class="cx"> # on whether there is an overlap or not.
</span><span class="cx"> # NB Do this in reverse order so that the date farthest in the future is tested first - that will
</span><span class="lines">@@ -904,25 +905,42 @@
</span><span class="cx"> end=str(makeTimedUTC(instance.end)),
</span><span class="cx"> )
</span><span class="cx">
</span><del>- yield generateFreeBusyInfo(testcal, fbinfo, tr, 0, uid, servertoserver=True, accountingItems=accounting if len(instances) == 1 else None)
</del><ins>+ if accounting is None:
+ yield generateFreeBusyInfo(testcal, fbinfo, tr, 0, uid, servertoserver=True)
+ else:
+ # Do this twice if cache is used and compare results
+ details1 = {}
+ yield generateFreeBusyInfo(testcal, fbinfo, tr, 0, uid, servertoserver=True, accountingItems=details1)
+ if "useCache" not in accounting[testcal.name()]:
+ accounting[testcal.name()]["useCache"] = details1
</ins><span class="cx">
</span><ins>+ if accounting[testcal.name()]["useCache"]["fb-cached"]:
+ fbinfo_nocache = ([], [], [])
+ details2 = {}
+ yield generateFreeBusyInfo(testcal, fbinfo_nocache, tr, 0, uid, servertoserver=True, accountingItems=details2, allowCache=False)
+ if "noCache" not in accounting[testcal.name()]:
+ accounting[testcal.name()]["noCache"] = details2
+ if fbinfo != fbinfo_nocache:
+ log.error("Auto-accept free busy cache inconsistent with database query")
+ accounting[testcal.name()]["badCache"] = (details1, details2)
+
</ins><span class="cx"> # If any fbinfo entries exist we have an overlap
</span><span class="cx"> if len(fbinfo[0]) or len(fbinfo[1]) or len(fbinfo[2]):
</span><span class="cx"> instance.free = False
</span><span class="cx"> if accounting is not None:
</span><del>- accounting["tr"].insert(0, (tr.attributes["start"], tr.attributes["end"], instance.free,))
</del><ins>+ accounting[testcal.name()]["tr"].insert(0, (tr.attributes["start"], tr.attributes["end"], instance.free,))
</ins><span class="cx"> except QueryMaxResources:
</span><span class="cx"> instance.free = False
</span><span class="cx"> log.info("Exceeded number of matches whilst trying to find free-time.")
</span><span class="cx"> if accounting is not None:
</span><del>- accounting["problem"] = "Exceeded number of matches"
</del><ins>+ accounting[testcal.name()]["problem"] = "Exceeded number of matches"
</ins><span class="cx">
</span><span class="cx"> # If everything is declined we can exit now
</span><span class="cx"> if not any([instance.free for instance in instances]):
</span><span class="cx"> break
</span><span class="cx">
</span><del>- if accounting is not None:
- accounting["tr"] = accounting["tr"][:30]
</del><ins>+ if accounting is not None:
+ accounting[testcal.name()]["tr"] = accounting[testcal.name()]["tr"][:30]
</ins><span class="cx">
</span><span class="cx"> # Now adjust the instance.partstat currently set to "NEEDS-ACTION" to the
</span><span class="cx"> # value determined by auto-accept logic based on instance.free state. However,
</span></span></pre>
</div>
</div>
</body>
</html>