[CalendarServer-changes] [7968] CalendarServer/branches/users/glyph/imip-and-admin-html/ calendarserver/webadmin
source_changes at macosforge.org
source_changes at macosforge.org
Thu Aug 11 21:52:59 PDT 2011
Revision: 7968
http://trac.macosforge.org/projects/calendarserver/changeset/7968
Author: glyph at apple.com
Date: 2011-08-11 21:52:59 -0700 (Thu, 11 Aug 2011)
Log Message:
-----------
no-proxies message
Modified Paths:
--------------
CalendarServer/branches/users/glyph/imip-and-admin-html/calendarserver/webadmin/resource.py
CalendarServer/branches/users/glyph/imip-and-admin-html/calendarserver/webadmin/template.html
Modified: CalendarServer/branches/users/glyph/imip-and-admin-html/calendarserver/webadmin/resource.py
===================================================================
--- CalendarServer/branches/users/glyph/imip-and-admin-html/calendarserver/webadmin/resource.py 2011-08-12 04:52:45 UTC (rev 7967)
+++ CalendarServer/branches/users/glyph/imip-and-admin-html/calendarserver/webadmin/resource.py 2011-08-12 04:52:59 UTC (rev 7968)
@@ -283,22 +283,24 @@
return tag
- @renderer
- def noProxies(self, request, tag):
+ _matrix = None
+
+ @inlineCallbacks
+ def proxyMatrix(self):
"""
- Renderer which shows its tag if there are no proxies for this resource.
- """
- return tag
+ Compute a matrix of proxies to display in a 2-column table.
+ This value is cached so that multiple renderers may refer to it without
+ causing additional back-end queries.
- @renderer
- @inlineCallbacks
- def proxyRows(self, request, tag):
+ @return: a L{Deferred} which fires with a list of 2-tuples of
+ (readProxy, writeProxy). If there is an unequal number of read and
+ write proxies, the tables will be padded out with C{None}s so that
+ some readProxy or writeProxy values will be C{None} at the end of
+ the table.
"""
- Renderer which does zipping logic to render read-only and read-write
- rows of existing proxies for the currently-viewed resource.
- """
- result = []
+ if self._matrix is not None:
+ returnValue(self._matrix)
(readSubPrincipal, writeSubPrincipal) = (
proxySubprincipal(self.principalResource, "read"),
proxySubprincipal(self.principalResource, "write")
@@ -325,12 +327,49 @@
writeProxies += [None] * lendiff
elif lendiff < 0:
readProxies += [None] * lendiff
- for idx, (readProxy, writeProxy) in enumerate(
- zip(readProxies, writeProxies)
- ):
- result.append(
- ProxyRow(tag.clone(), idx, readProxy, writeProxy)
- )
+ self._matrix = zip(readProxies, writeProxies)
+ else:
+ self._matrix = []
+ else:
+ self._matrix = []
+ returnValue(self._matrix)
+
+
+ @renderer
+ @inlineCallbacks
+ def noProxies(self, request, tag):
+ """
+ Renderer which shows its tag if there are no proxies for this resource.
+ """
+ mtx = yield self.proxyMatrix()
+ if mtx:
+ returnValue("")
+ returnValue(tag)
+
+
+ @renderer
+ @inlineCallbacks
+ def hasProxies(self, request, tag):
+ """
+ Renderer which shows its tag if there are any proxies for this resource.
+ """
+ mtx = yield self.proxyMatrix()
+ if mtx:
+ returnValue(tag)
+ returnValue("")
+
+
+ @renderer
+ @inlineCallbacks
+ def proxyRows(self, request, tag):
+ """
+ Renderer which does zipping logic to render read-only and read-write
+ rows of existing proxies for the currently-viewed resource.
+ """
+ result = []
+ mtx = yield self.proxyMatrix()
+ for idx, (readProxy, writeProxy) in enumerate(mtx):
+ result.append(ProxyRow(tag.clone(), idx, readProxy, writeProxy))
returnValue(result)
Modified: CalendarServer/branches/users/glyph/imip-and-admin-html/calendarserver/webadmin/template.html
===================================================================
--- CalendarServer/branches/users/glyph/imip-and-admin-html/calendarserver/webadmin/template.html 2011-08-12 04:52:45 UTC (rev 7967)
+++ CalendarServer/branches/users/glyph/imip-and-admin-html/calendarserver/webadmin/template.html 2011-08-12 04:52:59 UTC (rev 7968)
@@ -141,7 +141,8 @@
><t:attr name="value"><t:slot name="resourceId" /></t:attr></input>
<div t:render="noProxies" style="margin-top:15px"
>This resource has no proxies.</div>
- <table cellspacing="0" cellpadding="3" border="1">
+ <table cellspacing="0" cellpadding="3" border="1"
+ t:render="hasProxies">
<tr class="odd">
<th colspan="2">Read-Only Proxies</th>
<th colspan="2">Read-Write Proxies</th>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110811/9ebf95e5/attachment-0001.html>
More information about the calendarserver-changes
mailing list