[CalendarServer-changes] [2522] CalendarServer/trunk/lib-patches/Twisted
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jun 2 16:29:46 PDT 2008
Revision: 2522
http://trac.macosforge.org/projects/calendarserver/changeset/2522
Author: cdaboo at apple.com
Date: 2008-06-02 16:29:45 -0700 (Mon, 02 Jun 2008)
Log Message:
-----------
Add support for the DAV:current-user-principal property.
(http://tools.ietf.org/html/draft-sanchez-webdav-current-principal-01)
Modified Paths:
--------------
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.davxml.patch
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.element.__init__.patch
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch
Added Paths:
-----------
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.element.extensions.patch
Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.davxml.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.davxml.patch 2008-06-02 16:23:48 UTC (rev 2521)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.davxml.patch 2008-06-02 23:29:45 UTC (rev 2522)
@@ -2,19 +2,21 @@
===================================================================
--- twisted/web2/dav/davxml.py (revision 19773)
+++ twisted/web2/dav/davxml.py (working copy)
-@@ -45,6 +45,7 @@
+@@ -45,6 +45,8 @@
from twisted.web2.dav.element.rfc2518 import *
from twisted.web2.dav.element.rfc3253 import *
from twisted.web2.dav.element.rfc3744 import *
+from twisted.web2.dav.element.rfc4331 import *
++from twisted.web2.dav.element.extensions import *
#
# Register all XML elements with the parser
-@@ -56,11 +57,13 @@
+@@ -56,11 +58,15 @@
import twisted.web2.dav.element.rfc2518
import twisted.web2.dav.element.rfc3253
import twisted.web2.dav.element.rfc3744
+import twisted.web2.dav.element.rfc4331
++import twisted.web2.dav.element.extensions
__all__ = (
registerElements(twisted.web2.dav.element.base ) +
@@ -23,5 +25,6 @@
registerElements(twisted.web2.dav.element.rfc3253) +
- registerElements(twisted.web2.dav.element.rfc3744)
+ registerElements(twisted.web2.dav.element.rfc3744) +
-+ registerElements(twisted.web2.dav.element.rfc4331)
++ registerElements(twisted.web2.dav.element.rfc4331) +
++ registerElements(twisted.web2.dav.element.extensions)
)
Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.element.__init__.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.element.__init__.patch 2008-06-02 16:23:48 UTC (rev 2521)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.element.__init__.patch 2008-06-02 23:29:45 UTC (rev 2522)
@@ -2,9 +2,10 @@
===================================================================
--- twisted/web2/dav/element/__init__.py (revision 19773)
+++ twisted/web2/dav/element/__init__.py (working copy)
-@@ -35,4 +35,5 @@
+@@ -35,4 +35,6 @@
"rfc2518",
"rfc3253",
"rfc3744",
+ "rfc4331",
++ "extensions",
]
Added: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.element.extensions.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.element.extensions.patch (rev 0)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.element.extensions.patch 2008-06-02 23:29:45 UTC (rev 2522)
@@ -0,0 +1,44 @@
+Index: twisted/web2/dav/element/extensions.py
+===================================================================
+--- twisted/web2/dav/element/extensions.py (revision 0)
++++ twisted/web2/dav/element/extensions.py (revision 0)
+@@ -0,0 +1,39 @@
++##
++# Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
++#
++# Permission is hereby granted, free of charge, to any person obtaining a copy
++# of this software and associated documentation files (the "Software"), to deal
++# in the Software without restriction, including without limitation the rights
++# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
++# copies of the Software, and to permit persons to whom the Software is
++# furnished to do so, subject to the following conditions:
++#
++# The above copyright notice and this permission notice shall be included in all
++# copies or substantial portions of the Software.
++#
++# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
++# SOFTWARE.
++#
++##
++
++from twisted.web2.dav.element.base import *
++
++##
++# draft-sanchez-webdav-current-principal
++##
++
++class CurrentUserPrincipal(WebDAVElement):
++ """
++ Current principal information
++ """
++
++ name = "current-user-principal"
++ allowed_children = {
++ (dav_namespace, "href" ) : (0, 1),
++ (dav_namespace, "unauthenticated" ) : (0, 1),
++ }
Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch 2008-06-02 16:23:48 UTC (rev 2521)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch 2008-06-02 23:29:45 UTC (rev 2522)
@@ -2,17 +2,16 @@
===================================================================
--- twisted/web2/dav/resource.py (revision 19773)
+++ twisted/web2/dav/resource.py (working copy)
-@@ -40,10 +40,18 @@
+@@ -40,10 +40,16 @@
"unauthenticatedPrincipal",
]
+-import urllib
+import __builtin__
+if not hasattr(__builtin__, "set"):
+ import sets.Set as set
+if not hasattr(__builtin__, "frozenset"):
+ import sets.ImmutableSet as frozenset
-+
- import urllib
from zope.interface import implements
from twisted.python import log
@@ -21,7 +20,7 @@
from twisted.internet.defer import Deferred, maybeDeferred, succeed
from twisted.internet.defer import waitForDeferred, deferredGenerator
from twisted.internet import reactor
-@@ -52,12 +60,13 @@
+@@ -52,12 +58,13 @@
from twisted.web2.http_headers import generateContentType
from twisted.web2.iweb import IResponse
from twisted.web2.resource import LeafResource
@@ -36,7 +35,12 @@
from twisted.web2.dav.http import NeedPrivilegesResponse
from twisted.web2.dav.noneprops import NonePropertyStore
from twisted.web2.dav.util import unimplemented, parentForURL, joinURL
-@@ -130,6 +139,8 @@
+@@ -126,10 +133,13 @@
+ #(dav_namespace, "group" ), # RFC 3744, section 5.2
+ (dav_namespace, "supported-privilege-set" ), # RFC 3744, section 5.3
+ (dav_namespace, "current-user-privilege-set"), # RFC 3744, section 5.4
++ (dav_namespace, "current-user-principal" ), # draft-sanchez-webdav-current-principal
+ (dav_namespace, "acl" ), # RFC 3744, section 5.5
(dav_namespace, "acl-restrictions" ), # RFC 3744, section 5.6
(dav_namespace, "inherited-acl-set" ), # RFC 3744, section 5.7
(dav_namespace, "principal-collection-set" ), # RFC 3744, section 5.8
@@ -45,7 +49,7 @@
(twisted_dav_namespace, "resource-class"),
)
-@@ -166,6 +177,14 @@
+@@ -166,6 +176,14 @@
if qname[0] == twisted_private_namespace:
return succeed(False)
@@ -60,7 +64,7 @@
return succeed(qname in self.liveProperties or self.deadProperties().contains(qname))
def readProperty(self, property, request):
-@@ -239,8 +258,10 @@
+@@ -239,8 +257,10 @@
)
if name == "supported-report-set":
@@ -73,7 +77,7 @@
if name == "supported-privilege-set":
return self.supportedPrivileges(request)
-@@ -252,9 +273,10 @@
+@@ -252,9 +272,10 @@
return davxml.InheritedACLSet(*self.inheritedACLSet())
if name == "principal-collection-set":
@@ -87,11 +91,14 @@
def ifAllowed(privileges, callback):
def onError(failure):
-@@ -286,7 +308,33 @@
+@@ -286,7 +307,36 @@
d.addCallback(gotACL)
return d
return ifAllowed((davxml.ReadACL(),), callback)
-+
++
++ if name == "current-user-principal":
++ return davxml.CurrentUserPrincipal(self.currentPrincipal(request).children[0])
+
+ if name == "quota-available-bytes":
+ def callback(qvalue):
+ if qvalue is None:
@@ -104,7 +111,7 @@
+ d = self.quota(request)
+ d.addCallback(callback)
+ return d
-
++
+ if name == "quota-used-bytes":
+ def callback(qvalue):
+ if qvalue is None:
@@ -121,7 +128,7 @@
elif namespace == twisted_dav_namespace:
if name == "resource-class":
class ResourceClass (davxml.WebDAVTextElement):
-@@ -363,15 +411,28 @@
+@@ -363,15 +413,28 @@
"""
See L{IDAVResource.listProperties}.
"""
@@ -154,7 +161,7 @@
def listAllprop(self, request):
"""
Some DAV properties should not be returned to a C{DAV:allprop} query.
-@@ -465,8 +526,22 @@
+@@ -465,8 +528,22 @@
return super(DAVPropertyMixIn, self).displayName()
class DAVResource (DAVPropertyMixIn, StaticRenderMixin):
@@ -177,7 +184,7 @@
##
# DAV
##
-@@ -570,19 +645,21 @@
+@@ -570,19 +647,21 @@
See L{IDAVResource.authorize}.
"""
def onError(failure):
@@ -204,7 +211,7 @@
response = UnauthorizedResponse(request.credentialFactories,
request.remoteAddr)
else:
-@@ -593,7 +670,7 @@
+@@ -593,7 +672,7 @@
# class is supposed to be a FORBIDDEN status code and
# "Authorization will not help" according to RFC2616
#
@@ -213,7 +220,7 @@
d = self.checkPrivileges(request, privileges, recurse)
d.addErrback(onErrors)
-@@ -606,16 +683,21 @@
+@@ -606,16 +685,21 @@
def authenticate(self, request):
def loginSuccess(result):
@@ -239,7 +246,7 @@
authHeader = request.headers.getHeader('authorization')
-@@ -631,9 +713,10 @@
+@@ -631,9 +715,10 @@
# Try to match principals in each principal collection on the resource
def gotDetails(details):
@@ -253,7 +260,7 @@
def login(pcreds):
d = request.portal.login(pcreds, None, *request.loginInterfaces)
-@@ -641,13 +724,15 @@
+@@ -641,13 +726,15 @@
return d
@@ -273,7 +280,7 @@
##
# ACL
-@@ -656,49 +741,23 @@
+@@ -656,49 +743,23 @@
def currentPrincipal(self, request):
"""
@param request: the request being processed.
@@ -332,7 +339,7 @@
"""
@return: the L{davxml.ACL} element containing the default access control
list for this resource.
-@@ -710,6 +769,17 @@
+@@ -710,6 +771,17 @@
#
return readonlyACL
@@ -350,7 +357,7 @@
def setAccessControlList(self, acl):
"""
See L{IDAVResource.setAccessControlList}.
-@@ -748,13 +818,16 @@
+@@ -748,13 +820,16 @@
# 10. Verify that new acl is not in conflict with itself
# 11. Update acl on the resource
@@ -368,7 +375,7 @@
# Need to get list of supported privileges
supported = []
-@@ -1038,9 +1111,9 @@
+@@ -1038,9 +1113,9 @@
if myURL == "/":
# If we get to the root without any ACLs, then use the default.
@@ -380,7 +387,7 @@
# Dynamically update privileges for those ace's that are inherited.
if inheritance:
-@@ -1076,7 +1149,7 @@
+@@ -1076,7 +1151,7 @@
# Adjust ACE for inherit on this resource
children = list(ace.children)
children.remove(TwistedACLInheritable())
@@ -389,7 +396,7 @@
aces.append(davxml.ACE(*children))
else:
aces.extend(inherited_aces)
-@@ -1105,8 +1178,7 @@
+@@ -1105,8 +1180,7 @@
the child resource loop and supply those to the checkPrivileges on each child.
@param request: the L{IRequest} for the request in progress.
@@ -399,7 +406,7 @@
"""
# Get the parent ACLs with inheritance and preserve the <inheritable> element.
-@@ -1128,21 +1200,9 @@
+@@ -1128,21 +1202,9 @@
# Adjust ACE for inherit on this resource
children = list(ace.children)
children.remove(TwistedACLInheritable())
@@ -423,7 +430,7 @@
inheritedACEsforChildren = deferredGenerator(inheritedACEsforChildren)
-@@ -1152,49 +1212,69 @@
+@@ -1152,49 +1214,69 @@
This implementation returns an empty set.
"""
@@ -521,7 +528,7 @@
def samePrincipal(self, principal1, principal2):
"""
Check whether the two prinicpals are exactly the same in terms of
-@@ -1219,7 +1299,6 @@
+@@ -1219,7 +1301,6 @@
return False
def matchPrincipal(self, principal1, principal2, request):
@@ -529,7 +536,7 @@
"""
Check whether the principal1 is a principal in the set defined by
principal2.
-@@ -1244,6 +1323,9 @@
+@@ -1244,6 +1325,9 @@
if isinstance(principal1, davxml.Unauthenticated):
yield False
return
@@ -539,7 +546,7 @@
else:
yield True
return
-@@ -1271,7 +1353,6 @@
+@@ -1271,7 +1355,6 @@
assert principal2 is not None, "principal2 is None"
@@ -547,7 +554,7 @@
# Compare two HRefs and do group membership test as well
if principal1 == principal2:
yield True
-@@ -1289,6 +1370,7 @@
+@@ -1289,6 +1372,7 @@
matchPrincipal = deferredGenerator(matchPrincipal)
@@ -555,7 +562,7 @@
def principalIsGroupMember(self, principal1, principal2, request):
"""
Check whether one principal is a group member of another.
-@@ -1299,18 +1381,21 @@
+@@ -1299,18 +1383,21 @@
@return: L{Deferred} with result C{True} if principal1 is a member of principal2, C{False} otherwise
"""
@@ -588,7 +595,7 @@
def validPrincipal(self, ace_principal, request):
"""
-@@ -1351,11 +1436,16 @@
+@@ -1351,11 +1438,16 @@
@return C{True} if C{href_principal} is valid, C{False} otherwise.
This implementation tests for a href element that corresponds to
@@ -608,7 +615,7 @@
return d
def resolvePrincipal(self, principal, request):
-@@ -1432,7 +1522,7 @@
+@@ -1432,7 +1524,7 @@
log.err("DAV:self ACE is set on non-principal resource %r" % (self,))
yield None
return
@@ -617,7 +624,7 @@
if isinstance(principal, davxml.HRef):
yield principal
-@@ -1517,6 +1607,270 @@
+@@ -1517,6 +1609,270 @@
return None
##
@@ -888,7 +895,7 @@
# HTTP
##
-@@ -1525,10 +1879,6 @@
+@@ -1525,10 +1881,6 @@
#litmus = request.headers.getRawHeaders("x-litmus")
#if litmus: log.msg("*** Litmus test: %s ***" % (litmus,))
@@ -899,7 +906,7 @@
#
# If this is a collection and the URI doesn't end in "/", redirect.
#
-@@ -1567,7 +1917,7 @@
+@@ -1567,7 +1919,7 @@
def findChildren(self, depth, request, callback, privileges=None, inherited_aces=None):
return succeed(None)
@@ -908,7 +915,7 @@
"""
Resource representing a WebDAV principal. (RFC 3744, section 2)
"""
-@@ -1577,7 +1927,7 @@
+@@ -1577,7 +1929,7 @@
# WebDAV
##
@@ -917,7 +924,7 @@
(dav_namespace, "alternate-URI-set"),
(dav_namespace, "principal-URL" ),
(dav_namespace, "group-member-set" ),
-@@ -1585,14 +1935,11 @@
+@@ -1585,14 +1937,11 @@
)
def davComplianceClasses(self):
@@ -933,7 +940,7 @@
def readProperty(self, property, request):
def defer():
if type(property) is tuple:
-@@ -1610,10 +1957,20 @@
+@@ -1610,10 +1959,20 @@
return davxml.PrincipalURL(davxml.HRef(self.principalURL()))
if name == "group-member-set":
@@ -956,7 +963,7 @@
if name == "resourcetype":
if self.isCollection():
-@@ -1655,7 +2012,7 @@
+@@ -1655,7 +2014,7 @@
principals. Subclasses should override this method to provide member
URLs for this resource if appropriate.
"""
@@ -965,7 +972,7 @@
def groupMemberships(self):
"""
-@@ -1666,6 +2023,7 @@
+@@ -1666,6 +2025,7 @@
"""
unimplemented(self)
@@ -973,7 +980,7 @@
def principalMatch(self, href):
"""
Check whether the supplied principal matches this principal or is a
-@@ -1675,10 +2033,33 @@
+@@ -1675,10 +2035,33 @@
"""
uri = str(href)
if self.principalURL() == uri:
@@ -1009,7 +1016,7 @@
class AccessDeniedError(Exception):
def __init__(self, errors):
"""
-@@ -1718,6 +2099,37 @@
+@@ -1718,6 +2101,37 @@
davxml.registerElement(TwistedACLInheritable)
davxml.ACE.allowed_children[(twisted_dav_namespace, "inheritable")] = (0, 1)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080602/84e0d9fb/attachment-0001.htm
More information about the calendarserver-changes
mailing list