[CalendarServer-changes] [8077] CalendarServer/branches/users/glyph/other-html/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Tue Sep 13 12:10:20 PDT 2011
Revision: 8077
http://trac.macosforge.org/projects/calendarserver/changeset/8077
Author: glyph at apple.com
Date: 2011-09-13 12:10:20 -0700 (Tue, 13 Sep 2011)
Log Message:
-----------
functional placeholders for principals and proxies.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/calendar-user-proxy-principal-resource.html
CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/calendaruserproxy.py
CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/directory-principal-resource.html
CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/principal.py
CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory-listing.html
CalendarServer/branches/users/glyph/other-html/twistedcaldav/extensions.py
Modified: CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/calendar-user-proxy-principal-resource.html
===================================================================
--- CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/calendar-user-proxy-principal-resource.html 2011-09-13 19:10:11 UTC (rev 8076)
+++ CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/calendar-user-proxy-principal-resource.html 2011-09-13 19:10:20 UTC (rev 8077)
@@ -4,7 +4,7 @@
<t:transparent xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1"
t:render="principal">
<div class="directory-listing">
- <h1>Principal Details</h1>
+ <h1>Proxy Principal Details</h1>
<pre><blockquote>Directory Information
---------------------
Directory GUID: <t:slot name="directoryGUID"></t:slot>
@@ -32,7 +32,4 @@
<t:slot name="groupMemberships"></t:slot>
</blockquote></pre>
</div>
-<t:transparent t:render="output">
-<!-- parent / superclass output goes here -->
</t:transparent>
-</t:transparent>
Modified: CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/calendaruserproxy.py
===================================================================
--- CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/calendaruserproxy.py 2011-09-13 19:10:11 UTC (rev 8076)
+++ CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/calendaruserproxy.py 2011-09-13 19:10:20 UTC (rev 8077)
@@ -40,6 +40,9 @@
from twext.python.log import Logger, LoggingMixIn
+from twisted.web.template import XMLFile, Element, renderer
+from twisted.python.modules import getModule
+from twistedcaldav.extensions import DirectoryElement
from twistedcaldav.config import config, fullServerPath
from twistedcaldav.database import AbstractADBAPIDatabase, ADBAPISqliteMixin,\
@@ -50,6 +53,7 @@
from twistedcaldav.memcacher import Memcacher
from twistedcaldav.resource import CalDAVComplianceMixIn
+thisModule = getModule(__name__)
log = Logger()
class PermissionsMixIn (ReadOnlyWritePropertiesResourceMixIn):
@@ -88,6 +92,59 @@
+class ProxyPrincipalDetailElement(Element):
+ """
+ Element that can render the details of a
+ L{CalendarUserProxyPrincipalResource}.
+ """
+
+ loader = XMLFile(thisModule.filePath.sibling(
+ "calendar-user-proxy-principal-resource.html").open()
+ )
+
+ def __init__(self, resource):
+ super(ProxyPrincipalDetailElement, self).__init__()
+ self.resource = resource
+
+
+ @renderer
+ def principal(self, request, tag):
+ """
+ Top-level renderer in the template.
+ """
+ return tag.fillSlots(
+ directoryGUID="<PLACEHOLDER>",
+ realm="<PLACEHOLDER>",
+ guid="<PLACEHOLDER>",
+ recordType="<PLACEHOLDER>",
+ shortNames="<PLACEHOLDER>",
+ fullName="<PLACEHOLDER>",
+ principalUID="<PLACEHOLDER>",
+ principalURL="<PLACEHOLDER>",
+ proxyPrincipalUID="<PLACEHOLDER>",
+ proxyPrincipalURL="<PLACEHOLDER>",
+ alternateURIs="<PLACEHOLDER>",
+ groupMembers="<PLACEHOLDER>",
+ groupMemberships="<PLACEHOLDER>",
+ )
+
+
+
+
+class ProxyPrincipalElement(DirectoryElement):
+ """
+ L{ProxyPrincipalElement} is a renderer for proxy details.
+ """
+
+ @renderer
+ def resourceDetail(self, request, tag):
+ """
+ Render the proxy principal's details.
+ """
+ return ProxyPrincipalDetailElement(self.resource)
+
+
+
class CalendarUserProxyPrincipalResource (
CalDAVComplianceMixIn, PermissionsMixIn, DAVResourceWithChildrenMixin,
DAVPrincipalResource):
@@ -239,6 +296,10 @@
# HTTP
##
+ def htmlElement(self):
+ return ProxyPrincipalElement(self)
+
+
def renderDirectoryBody(self, request):
# FIXME: Too much code duplication here from principal.py
from twistedcaldav.directory.principal import format_list, format_principals, format_link
Modified: CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/directory-principal-resource.html
===================================================================
--- CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/directory-principal-resource.html 2011-09-13 19:10:11 UTC (rev 8076)
+++ CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/directory-principal-resource.html 2011-09-13 19:10:20 UTC (rev 8077)
@@ -1,6 +1,7 @@
<div xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1"
t:render="principal" class="directory-listing">
- <h1>Principal Details</h1><pre><blockquote>Directory Information
+ <h1>Principal Details</h1>
+ <pre><blockquote>Directory Information
---------------------
Directory GUID: <t:slot name="directoryGUID"></t:slot>
Realm: <t:slot name="realm"></t:slot>
@@ -29,13 +30,12 @@
<t:slot name="readWriteProxyFor"></t:slot>
Read-only Proxy For:
<t:slot name="readOnlyProxyFor"></t:slot><t:transparent
-t:render="extra"><t:transparent t:render="enabledForCalendaring" />
-Calendar Homes: <t:slot name="calendarHomes" />
-Calendar user addresses: <t:slot name="calendarUserAddresses" /><t:transparent
+t:render="extra"><t:transparent t:render="enabledForCalendaring">
+Calendar Homes:
+<t:slot name="calendarHomes" />
+Calendar user addresses:
+<t:slot name="calendarUserAddresses" /></t:transparent><t:transparent
t:render="enabledForAddressBooks">
Address Book homes:<t:slot name="addressBookHomes" />
-</t:transparent></t:transparent>
-</blockquote></pre>
-
- </div>
-
+</t:transparent></t:transparent></blockquote></pre>
+</div>
Modified: CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/principal.py 2011-09-13 19:10:11 UTC (rev 8076)
+++ CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory/principal.py 2011-09-13 19:10:20 UTC (rev 8077)
@@ -39,6 +39,8 @@
from twisted.python.failure import Failure
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.internet.defer import succeed
+from twisted.web.template import XMLFile, Element, renderer
+
from twext.web2.auth.digest import DigestedCredentials
from twext.web2 import responsecode
from twext.web2.http import HTTPError
@@ -53,9 +55,12 @@
NegotiateCredentials # sigh, pyflakes
except ImportError:
NegotiateCredentials = None
+from twisted.python.modules import getModule
from twistedcaldav.config import config
from twistedcaldav.cache import DisabledCacheNotifier, PropfindCacheMixin
+
from twistedcaldav.directory import calendaruserproxy
+from twistedcaldav.extensions import DirectoryElement
from twistedcaldav.directory.calendaruserproxy import (
CalendarUserProxyPrincipalResource
)
@@ -71,13 +76,16 @@
from twistedcaldav.customxml import calendarserver_namespace
from twistedcaldav.scheduling.cuaddress import normalizeCUAddr
+thisModule = getModule(__name__)
log = Logger()
+
class PermissionsMixIn (ReadOnlyResourceMixIn):
def defaultAccessControlList(self):
return authReadACL
- def accessControlList(self, request, inheritance=True, expanding=False, inherited_aces=None):
+ def accessControlList(self, request, inheritance=True, expanding=False,
+ inherited_aces=None):
return succeed(self.defaultAccessControlList())
@@ -492,6 +500,95 @@
def principalCollections(self):
return self.parent.principalCollections()
+
+
+class DirectoryPrincipalDetailElement(Element):
+ """
+ Element that can render the details of a
+ L{CalendarUserDirectoryPrincipalResource}.
+ """
+
+ loader = XMLFile(thisModule.filePath.sibling(
+ "directory-principal-resource.html").open()
+ )
+
+ def __init__(self, resource):
+ super(DirectoryPrincipalDetailElement, self).__init__()
+ self.resource = resource
+
+
+ @renderer
+ def principal(self, request, tag):
+ """
+ Top-level renderer in the template.
+ """
+ return tag.fillSlots(
+ directoryGUID="<PLACEHOLDER>",
+ realm="<PLACEHOLDER>",
+ hostedAt="<PLACEHOLDER>",
+ partition="<PLACEHOLDER>",
+ principalGUID="<PLACEHOLDER>",
+ recordType="<PLACEHOLDER>",
+ shortNames="<PLACEHOLDER>",
+ securityIDs="<PLACEHOLDER>",
+ fullName="<PLACEHOLDER>",
+ firstName="<PLACEHOLDER>",
+ lastName="<PLACEHOLDER>",
+ principalUID="<PLACEHOLDER>",
+ principalURL="<PLACEHOLDER>",
+ alternateURIs="<PLACEHOLDER>",
+ groupMembers="<PLACEHOLDER>",
+ groupMemberships="<PLACEHOLDER>",
+ readWriteProxyFor="<PLACEHOLDER>",
+ readOnlyProxyFor="<PLACEHOLDER>",
+ calendarHomes="<PLACEHOLDER>",
+ calendarUserAddresses="<PLACEHOLDER>",
+ addressBookHomes="<PLACEHOLDER>",
+ )
+
+
+ @renderer
+ def extra(self, request, tag):
+ """
+ Renderer for extra directory body items for calendar/addressbook
+ principals.
+ """
+ return ''
+
+
+ @renderer
+ def enabledForCalendaring(self, request, tag):
+ """
+ Renderer which returns its tag when the wrapped record is enabled for
+ calendaring.
+ """
+ return ''
+
+
+ @renderer
+ def enabledForAddressBooks(self, request, tag):
+ """
+ Renderer which returnst its tag when the wrapped record is enabled for
+ addressbooks.
+ """
+ return ''
+
+
+
+class DirectoryPrincipalElement(DirectoryElement):
+ """
+ L{DirectoryPrincipalElement} is a renderer for directory details.
+ """
+
+ @renderer
+ def resourceDetail(self, request, tag):
+ """
+ Render the directory principal's details.
+ """
+ return DirectoryPrincipalDetailElement(self.resource)
+
+
+
class DirectoryPrincipalResource (
PropfindCacheMixin, PermissionsMixIn, DAVPrincipalResource):
"""
@@ -585,6 +682,9 @@
# HTTP
##
+ def htmlElement(self):
+ return DirectoryPrincipalElement(self)
+
@inlineCallbacks
def renderDirectoryBody(self, request):
Modified: CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory-listing.html
===================================================================
--- CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory-listing.html 2011-09-13 19:10:11 UTC (rev 8076)
+++ CalendarServer/branches/users/glyph/other-html/twistedcaldav/directory-listing.html 2011-09-13 19:10:20 UTC (rev 8077)
@@ -31,6 +31,7 @@
}
</style>
<body>
+ <t:transparent t:render="resourceDetail" />
<div class="directory-listing">
<h1>Collection Listing</h1>
<table>
Modified: CalendarServer/branches/users/glyph/other-html/twistedcaldav/extensions.py
===================================================================
--- CalendarServer/branches/users/glyph/other-html/twistedcaldav/extensions.py 2011-09-13 19:10:11 UTC (rev 8076)
+++ CalendarServer/branches/users/glyph/other-html/twistedcaldav/extensions.py 2011-09-13 19:10:20 UTC (rev 8077)
@@ -473,6 +473,15 @@
@renderer
+ def resourceDetail(self, request, tag):
+ """
+ Renderer which returns a distinct element for this resource's data.
+ Subclasses should override.
+ """
+ return ''
+
+
+ @renderer
def children(self, request, tag):
"""
Renderer which yields all child object tags as table rows.
@@ -490,12 +499,13 @@
@whenChildren.addCallback
def gotChildren(children):
for even, [child, name] in zip(cycle(["even", "odd"]), children):
- [url, name, size, lastModified, contentType] = (
- self.resource.getChildDirectoryEntry(child, name, request)
+ [url, name, size, lastModified, contentType] = map(
+ str, self.resource.getChildDirectoryEntry(
+ child, name, request)
)
yield tag.clone().fillSlots(
- url=url, name=name, size=str(size), lastModified=lastModified,
- even=even, type=contentType,
+ url=url, name=name, size=str(size),
+ lastModified=lastModified, even=even, type=contentType,
)
return whenChildren
@@ -567,9 +577,17 @@
MimeType("text", "html", mime_params)
)
return response
- return flattenString(request, DirectoryElement(self)).addCallback(gotBody)
+ return flattenString(request, self.htmlElement()).addCallback(gotBody)
+ def htmlElement(self):
+ """
+ Create a L{DirectoryElement} or appropriate subclass for rendering this
+ resource.
+ """
+ return DirectoryElement(self)
+
+
def getChildDirectoryEntry(self, child, name, request):
def orNone(value, default="?", f=None):
if value is None:
@@ -617,7 +635,7 @@
if rtypes:
contentType = "(%s)" % (", ".join(rtypes),)
- return ((
+ return (
url,
name,
orNone(size),
@@ -625,9 +643,9 @@
lastModified,
default="",
f=lambda t: time.strftime("%Y-%b-%d %H:%M", time.localtime(t))
- ),
- contentType,
- ))
+ ),
+ contentType,
+ )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110913/9142d673/attachment-0001.html>
More information about the calendarserver-changes
mailing list