<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[1132] CalendarServer/trunk/twistedcaldav</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.macosforge.org/projects/calendarserver/changeset/1132">1132</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2007-02-06 10:28:24 -0800 (Tue, 06 Feb 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>Rename getDirectoryTable() to renderDirectoryBody() and subclass that
in order to get better code re-use from renderDirectory().</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktwistedcaldavdirectoryprincipalpy">CalendarServer/trunk/twistedcaldav/directory/principal.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavextensionspy">CalendarServer/trunk/twistedcaldav/extensions.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunktwistedcaldavdirectoryprincipalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/directory/principal.py (1131 => 1132)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/directory/principal.py        2007-02-06 00:31:27 UTC (rev 1131)
+++ CalendarServer/trunk/twistedcaldav/directory/principal.py        2007-02-06 18:28:24 UTC (rev 1132)
</span><span class="lines">@@ -285,7 +285,7 @@
</span><span class="cx">     # HTTP
</span><span class="cx">     ##
</span><span class="cx"> 
</span><del>-    def render(self, request):
</del><ins>+    def renderDirectoryBody(self, request):
</ins><span class="cx">         def format_list(items, *args):
</span><span class="cx">             def genlist():
</span><span class="cx">                 try:
</span><span class="lines">@@ -300,66 +300,38 @@
</span><span class="cx">                     yield &quot;  ** %s **: %s\n&quot; % (e.__class__.__name__, e)
</span><span class="cx">             return &quot;&quot;.join(genlist())
</span><span class="cx"> 
</span><del>-        output = [
-            &quot;&quot;&quot;&lt;html&gt;&quot;&quot;&quot;
-            &quot;&quot;&quot;&lt;head&gt;&quot;&quot;&quot;
-            &quot;&quot;&quot;&lt;title&gt;%(title)s&lt;/title&gt;&quot;&quot;&quot;
-            &quot;&quot;&quot;&lt;style&gt;%(style)s&lt;/style&gt;&quot;&quot;&quot;
-            &quot;&quot;&quot;&lt;/head&gt;&quot;&quot;&quot;
-            &quot;&quot;&quot;&lt;body&gt;&quot;&quot;&quot;
-            &quot;&quot;&quot;&lt;div class=&quot;directory-listing&quot;&gt;&quot;&quot;&quot;
-            &quot;&quot;&quot;&lt;h1&gt;Principal Details&lt;/h1&gt;&quot;&quot;&quot;
-            &quot;&quot;&quot;&lt;pre&gt;&lt;blockquote&gt;&quot;&quot;&quot;
-            % {
-                &quot;title&quot;: unquote(request.uri),
-                &quot;style&quot;: self.directoryStyleSheet(),
-            }
-        ]
-
</del><span class="cx">         def link(url):
</span><span class="cx">             return &quot;&quot;&quot;&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;&quot;&quot;&quot; % (url, url)
</span><span class="cx"> 
</span><del>-        output.append(&quot;&quot;.join((
-            &quot;Directory Information\n&quot;
-            &quot;---------------------\n&quot;
-            &quot;Directory GUID: %s\n&quot;         % (self.record.service.guid,),
-            &quot;Realm: %s\n&quot;                  % (self.record.service.realmName,),
-            &quot;\n&quot;
-            &quot;Principal Information\n&quot;
-            &quot;---------------------\n&quot;
-            &quot;GUID: %s\n&quot;                   % (self.record.guid,),
-            &quot;Record type: %s\n&quot;            % (self.record.recordType,),
-            &quot;Short name: %s\n&quot;             % (self.record.shortName,),
-            &quot;Full name: %s\n&quot;              % (self.record.fullName,),
-            &quot;Principal UID: %s\n&quot;          % (self.principalUID(),),
-            &quot;Principal URL: %s\n&quot;          % (link(self.principalURL()),),
-            &quot;\nAlternate URIs:\n&quot;          , format_list(self.alternateURIs()),
-            &quot;\nGroup members:\n&quot;           , format_list(link(p.principalURL()) for p in self.groupMembers()),
-            &quot;\nGroup memberships:\n&quot;       , format_list(link(p.principalURL()) for p in self.groupMemberships()),
-            &quot;\nCalendar homes:\n&quot;          , format_list(link(u) for u in self.calendarHomeURLs()),
-            &quot;\nCalendar user addresses:\n&quot; , format_list(link(a) for a in self.calendarUserAddresses()),
-        )))
</del><ins>+        def gotSuper(output):
+            return &quot;&quot;.join((
+                &quot;&quot;&quot;&lt;div class=&quot;directory-listing&quot;&gt;&quot;&quot;&quot;
+                &quot;&quot;&quot;&lt;h1&gt;Principal Details&lt;/h1&gt;&quot;&quot;&quot;
+                &quot;&quot;&quot;&lt;pre&gt;&lt;blockquote&gt;&quot;&quot;&quot;
+                &quot;&quot;&quot;Directory Information\n&quot;&quot;&quot;
+                &quot;&quot;&quot;---------------------\n&quot;&quot;&quot;
+                &quot;&quot;&quot;Directory GUID: %s\n&quot;&quot;&quot;         % (self.record.service.guid,),
+                &quot;&quot;&quot;Realm: %s\n&quot;&quot;&quot;                  % (self.record.service.realmName,),
+                &quot;&quot;&quot;\n&quot;&quot;&quot;
+                &quot;&quot;&quot;Principal Information\n&quot;&quot;&quot;
+                &quot;&quot;&quot;---------------------\n&quot;&quot;&quot;
+                &quot;&quot;&quot;GUID: %s\n&quot;&quot;&quot;                   % (self.record.guid,),
+                &quot;&quot;&quot;Record type: %s\n&quot;&quot;&quot;            % (self.record.recordType,),
+                &quot;&quot;&quot;Short name: %s\n&quot;&quot;&quot;             % (self.record.shortName,),
+                &quot;&quot;&quot;Full name: %s\n&quot;&quot;&quot;              % (self.record.fullName,),
+                &quot;&quot;&quot;Principal UID: %s\n&quot;&quot;&quot;          % (self.principalUID(),),
+                &quot;&quot;&quot;Principal URL: %s\n&quot;&quot;&quot;          % (link(self.principalURL()),),
+                &quot;&quot;&quot;\nAlternate URIs:\n&quot;&quot;&quot;          , format_list(self.alternateURIs()),
+                &quot;&quot;&quot;\nGroup members:\n&quot;&quot;&quot;           , format_list(link(p.principalURL()) for p in self.groupMembers()),
+                &quot;&quot;&quot;\nGroup memberships:\n&quot;&quot;&quot;       , format_list(link(p.principalURL()) for p in self.groupMemberships()),
+                &quot;&quot;&quot;\nCalendar homes:\n&quot;&quot;&quot;          , format_list(link(u) for u in self.calendarHomeURLs()),
+                &quot;&quot;&quot;\nCalendar user addresses:\n&quot;&quot;&quot; , format_list(link(a) for a in self.calendarUserAddresses()),
+                &quot;&quot;&quot;&lt;/pre&gt;&lt;/blockquote&gt;&lt;/div&gt;&quot;&quot;&quot;,
+                output
+            ))
</ins><span class="cx"> 
</span><del>-        output.append(&quot;&lt;/pre&gt;&lt;/blockquote&gt;&lt;/div&gt;&quot;)
-
-        def gotTable(table, output=output):
-            output.append(table)
-            output.append(&quot;&lt;/body&gt;&lt;/html&gt;&quot;)
-            output = &quot;&quot;.join(output)
-
-            if type(output) == unicode:
-                output = output.encode(&quot;utf-8&quot;)
-                mime_params = {&quot;charset&quot;: &quot;utf-8&quot;}
-            else:
-                mime_params = {}
-
-            response = Response(code=responsecode.OK, stream=output)
-            response.headers.setHeader(&quot;content-type&quot;, MimeType(&quot;text&quot;, &quot;html&quot;, mime_params))
-
-            return response
-
-        d = self.getDirectoryTable(request)
-        d.addCallback(gotTable)
</del><ins>+        d = super(DirectoryPrincipalResource, self).renderDirectoryBody(request)
+        d.addCallback(gotSuper)
</ins><span class="cx">         return d
</span><span class="cx"> 
</span><span class="cx">     ##
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavextensionspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/extensions.py (1131 => 1132)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/extensions.py        2007-02-06 00:31:27 UTC (rev 1131)
+++ CalendarServer/trunk/twistedcaldav/extensions.py        2007-02-06 18:28:24 UTC (rev 1132)
</span><span class="lines">@@ -205,11 +205,11 @@
</span><span class="cx">             response.headers.setHeader(&quot;content-type&quot;, MimeType(&quot;text&quot;, &quot;html&quot;))
</span><span class="cx">             return response
</span><span class="cx"> 
</span><del>-        d = self.getDirectoryTable(request)
</del><ins>+        d = self.renderDirectoryBody(request)
</ins><span class="cx">         d.addCallback(gotTable)
</span><span class="cx">         return d
</span><span class="cx"> 
</span><del>-    def getDirectoryTable(self, request):
</del><ins>+    def renderDirectoryBody(self, request):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Generate a directory listing table in HTML.
</span><span class="cx">         &quot;&quot;&quot;
</span></span></pre>
</div>
</div>

</body>
</html>