<!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>[13152] CalendarServer/branches/users/sagen/move2who-4/txweb2/dav/method/report_expand.py</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/13152">13152</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2014-04-03 18:36:35 -0700 (Thu, 03 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix logger</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserssagenmove2who4txweb2davmethodreport_expandpy">CalendarServer/branches/users/sagen/move2who-4/txweb2/dav/method/report_expand.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserssagenmove2who4txweb2davmethodreport_expandpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/txweb2/dav/method/report_expand.py (13151 => 13152)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/txweb2/dav/method/report_expand.py        2014-04-04 01:36:18 UTC (rev 13151)
+++ CalendarServer/branches/users/sagen/move2who-4/txweb2/dav/method/report_expand.py        2014-04-04 01:36:35 UTC (rev 13152)
</span><span class="lines">@@ -8,10 +8,10 @@
</span><span class="cx"> # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
</span><span class="cx"> # copies of the Software, and to permit persons to whom the Software is
</span><span class="cx"> # furnished to do so, subject to the following conditions:
</span><del>-# 
</del><ins>+#
</ins><span class="cx"> # The above copyright notice and this permission notice shall be included in all
</span><span class="cx"> # copies or substantial portions of the Software.
</span><del>-# 
</del><ins>+#
</ins><span class="cx"> # THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
</span><span class="cx"> # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
</span><span class="cx"> # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx"> def report_DAV__expand_property(self, request, expand_property):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Generate an expand-property REPORT. (RFC 3253, section 3.8)
</span><del>-    
</del><ins>+
</ins><span class="cx">     TODO: for simplicity we will only support one level of expansion.
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     # Verify root element
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx">     if depth != &quot;0&quot;:
</span><span class="cx">         log.error(&quot;Non-zero depth is not allowed: %s&quot; % (depth,))
</span><span class="cx">         raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, &quot;Depth %s not allowed&quot; % (depth,)))
</span><del>-    
</del><ins>+
</ins><span class="cx">     #
</span><span class="cx">     # Get top level properties to expand and make sure we only have one level
</span><span class="cx">     #
</span><span class="lines">@@ -70,7 +70,7 @@
</span><span class="cx">     for property in expand_property.children:
</span><span class="cx">         namespace = property.attributes.get(&quot;namespace&quot;, dav_namespace)
</span><span class="cx">         name      = property.attributes.get(&quot;name&quot;, &quot;&quot;)
</span><del>-        
</del><ins>+
</ins><span class="cx">         # Make sure children have no children
</span><span class="cx">         props_to_find = []
</span><span class="cx">         for child in property.children:
</span><span class="lines">@@ -93,14 +93,14 @@
</span><span class="cx">         responsecode.OK        : [],
</span><span class="cx">         responsecode.NOT_FOUND : [],
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     filteredaces = None
</span><span class="cx">     lastParent = None
</span><span class="cx"> 
</span><span class="cx">     for qname in properties.iterkeys():
</span><span class="cx">         try:
</span><span class="cx">             prop = (yield self.readProperty(qname, request))
</span><del>-            
</del><ins>+
</ins><span class="cx">             # Form the PROPFIND-style DAV:prop element we need later
</span><span class="cx">             props_to_return = element.PropertyContainer(*properties[qname])
</span><span class="cx"> 
</span><span class="lines">@@ -108,27 +108,27 @@
</span><span class="cx">             responses = []
</span><span class="cx">             for href in prop.children:
</span><span class="cx">                 if isinstance(href, element.HRef):
</span><del>-                    
</del><ins>+
</ins><span class="cx">                     # Locate the Href resource and its parent
</span><span class="cx">                     resource_uri = str(href)
</span><span class="cx">                     child = (yield request.locateResource(resource_uri))
</span><del>-    
</del><ins>+
</ins><span class="cx">                     if not child or not child.exists():
</span><span class="cx">                         responses.append(element.StatusResponse(href, element.Status.fromResponseCode(responsecode.NOT_FOUND)))
</span><span class="cx">                         continue
</span><span class="cx">                     parent = (yield request.locateResource(parentForURL(resource_uri)))
</span><del>-    
</del><ins>+
</ins><span class="cx">                     # Check privileges on parent - must have at least DAV:read
</span><span class="cx">                     try:
</span><span class="cx">                         yield parent.checkPrivileges(request, (element.Read(),))
</span><span class="cx">                     except AccessDeniedError:
</span><span class="cx">                         responses.append(element.StatusResponse(href, element.Status.fromResponseCode(responsecode.FORBIDDEN)))
</span><span class="cx">                         continue
</span><del>-                    
</del><ins>+
</ins><span class="cx">                     # Cache the last parent's inherited aces for checkPrivileges optimization
</span><span class="cx">                     if lastParent != parent:
</span><span class="cx">                         lastParent = parent
</span><del>-                
</del><ins>+
</ins><span class="cx">                         # Do some optimisation of access control calculation by determining any inherited ACLs outside of
</span><span class="cx">                         # the child resource loop and supply those to the checkPrivileges on each child.
</span><span class="cx">                         filteredaces = (yield parent.inheritedACEsforChildren(request))
</span><span class="lines">@@ -139,7 +139,7 @@
</span><span class="cx">                     except AccessDeniedError:
</span><span class="cx">                         responses.append(element.StatusResponse(href, element.Status.fromResponseCode(responsecode.FORBIDDEN)))
</span><span class="cx">                         continue
</span><del>-            
</del><ins>+
</ins><span class="cx">                     # Now retrieve all the requested properties on the HRef resource
</span><span class="cx">                     yield prop_common.responseForHref(
</span><span class="cx">                         request,
</span><span class="lines">@@ -149,13 +149,16 @@
</span><span class="cx">                         prop_common.propertyListForResource,
</span><span class="cx">                         props_to_return,
</span><span class="cx">                     )
</span><del>-            
</del><ins>+
</ins><span class="cx">             prop.children = responses
</span><span class="cx">             properties_by_status[responsecode.OK].append(prop)
</span><span class="cx">         except:
</span><span class="cx">             f = Failure()
</span><span class="cx"> 
</span><del>-            log.error(&quot;Error reading property %r for resource %s: %s&quot; % (qname, request.uri, f.value))
</del><ins>+            log.error(
+                &quot;Error reading property {qname} for resource {req}: {failure}&quot;,
+                qname=qname, req=request.uri, failure=f.value
+            )
</ins><span class="cx"> 
</span><span class="cx">             status = statusForFailure(f, &quot;getting property: %s&quot; % (qname,))
</span><span class="cx">             if status not in properties_by_status: properties_by_status[status] = []
</span></span></pre>
</div>
</div>

</body>
</html>