[CalendarServer-changes] [9515] CalendarServer/branches/users/gaya/inviteclean/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Wed Aug 1 21:22:07 PDT 2012
Revision: 9515
http://trac.macosforge.org/projects/calendarserver/changeset/9515
Author: gaya at apple.com
Date: 2012-08-01 21:22:04 -0700 (Wed, 01 Aug 2012)
Log Message:
-----------
use simpler Share method names
Modified Paths:
--------------
CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py
CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharedcollection.py
CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py
Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py 2012-08-02 00:40:53 UTC (rev 9514)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py 2012-08-02 04:22:04 UTC (rev 9515)
@@ -706,7 +706,7 @@
isvirt = self.isVirtualShare()
if isvirt:
- returnValue(customxml.SharedURL(element.HRef.fromString(self._share.sharedResourceURL())))
+ returnValue(customxml.SharedURL(element.HRef.fromString(self._share.url())))
else:
returnValue(None)
@@ -934,7 +934,7 @@
isVirt = self.isVirtualShare()
if isVirt:
- parent = (yield self.locateParent(request, self._share.sharedResourceURL()))
+ parent = (yield self.locateParent(request, self._share.url()))
else:
parent = (yield self.locateParent(request, request.urlForResource(self)))
if parent and isinstance(parent, CalDAVResource):
@@ -950,7 +950,7 @@
"""
isVirt = self.isVirtualShare()
if isVirt:
- parent = (yield self.locateParent(request, self._share.sharedResourceURL()))
+ parent = (yield self.locateParent(request, self._share.url()))
else:
parent = (yield self.locateParent(request, request.urlForResource(self)))
if parent and isinstance(parent, CalDAVResource):
@@ -1366,14 +1366,14 @@
isvirt = self.isVirtualShare()
if isvirt:
# A virtual share's quota root is the resource owner's root
- sharedParent = (yield request.locateResource(parentForURL(self._share.sharedResourceURL())))
+ sharedParent = (yield request.locateResource(parentForURL(self._share.url())))
else:
parent = (yield self.locateParent(request, request.urlForResource(self)))
if isCalendarCollectionResource(parent) or isAddressBookCollectionResource(parent):
isvirt = parent.isVirtualShare()
if isvirt:
# A virtual share's quota root is the resource owner's root
- sharedParent = (yield request.locateResource(parentForURL(parent._share.sharedResourceURL())))
+ sharedParent = (yield request.locateResource(parentForURL(parent._share.url())))
if sharedParent:
result = (yield sharedParent.quotaRootResource(request))
Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharedcollection.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharedcollection.py 2012-08-02 00:40:53 UTC (rev 9514)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharedcollection.py 2012-08-02 04:22:04 UTC (rev 9515)
@@ -37,7 +37,7 @@
def __init__(self, parent, share):
self.share = share
- super(SharedCollectionResource, self).__init__(parent, self.share.sharedResourceURL())
+ super(SharedCollectionResource, self).__init__(parent, self.share.url())
@inlineCallbacks
def linkedResource(self, request):
@@ -46,13 +46,13 @@
"""
if not hasattr(self, "_linkedResource"):
- self._linkedResource = (yield request.locateResource(self.share.sharedResourceURL()))
+ self._linkedResource = (yield request.locateResource(self.share.url()))
if self._linkedResource is not None:
# FIXME: this is awkward - because we are "mutating" this object into a virtual share
# we must not cache the resource at this URL, otherwise an access of the owner's resource
# will return the same virtually shared one which would be wrong.
- request._forgetResource(self._linkedResource, self.share.sharedResourceURL())
+ request._forgetResource(self._linkedResource, self.share.url())
ownerPrincipal = (yield self.parent.ownerPrincipal(request))
self._linkedResource.setVirtualShare(ownerPrincipal, self.share)
Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py 2012-08-02 00:40:53 UTC (rev 9514)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py 2012-08-02 04:22:04 UTC (rev 9515)
@@ -93,7 +93,7 @@
# See if it is on the sharee calendar
if self.isVirtualShare():
- original = (yield request.locateResource(self._share.sharedResourceURL()))
+ original = (yield request.locateResource(self._share.url()))
yield original.validateInvites()
invitations = yield original._allInvitations()
@@ -301,8 +301,8 @@
wikiAccessMethod = kwargs.get("wikiAccessMethod", getWikiAccess)
# Direct shares use underlying privileges of shared collection
- if self._share.isDirect():
- original = (yield request.locateResource(self._share.sharedResourceURL()))
+ if self._share.direct():
+ original = (yield request.locateResource(self._share.url()))
owner = yield original.ownerPrincipal(request)
if owner.record.recordType == WikiDirectoryService.recordType_wikis:
# Access level comes from what the wiki has granted to the
@@ -1116,10 +1116,10 @@
elif self._newStoreHome._homeType == EADDRESSBOOKTYPE:
sharerHomeCollection = yield principal.addressBookHome(fakeRequest)
- sharedResourceURL = joinURL(sharerHomeCollection.url(), sharerHomeChild.name())
+ url = joinURL(sharerHomeCollection.url(), sharerHomeChild.name())
- share = Share(shareeHomeChild=shareeHomeChild, sharerHomeChild=sharerHomeChild, sharedResourceURL=sharedResourceURL)
+ share = Share(shareeHomeChild=shareeHomeChild, sharerHomeChild=sharerHomeChild, url=url)
shares.append(share)
# DEBUG ONLY
@@ -1137,7 +1137,7 @@
testStrings = []
for i in range(len(shares)):
share = shares[i]
- testStr = "i=%s, shareuid=%s, sharetype=%s, hostulr=%s, locqlname=%s, summary=%s" % (i, share.uid(), "D" if share.isDirect() else "I", share.sharedResourceURL(), share.shareeResourceName(), share.summary(), )
+ testStr = "i=%s, shareuid=%s, sharetype=%s, hostulr=%s, locqlname=%s, summary=%s" % (i, share.uid(), "D" if share.direct() else "I", share.url(), share.name(), share.summary(), )
testStrings += [testStr,]
if oTestStrings != testStrings:
@@ -1146,7 +1146,7 @@
assert False
- self._allShares = dict([(share.shareeResourceName(), share) for share in shares])
+ self._allShares = dict([(share.name(), share) for share in shares])
print ("allShares: GENERATED %d records, refresh=%s" % (len(self._allShares), refresh))
else:
@@ -1200,7 +1200,7 @@
returnValue(response)
@inlineCallbacks
- def _acceptShare(self, request, oldShare, isDirect, hostUrl, shareUID, displayname=None):
+ def _acceptShare(self, request, oldShare, direct, hostUrl, shareUID, displayname=None):
# Get shared collection in non-share mode first
sharedCollection = (yield request.locateResource(hostUrl))
@@ -1213,19 +1213,19 @@
#FIXME: add new share, then generate new from
- sharedCollectionRecord = SharedCollectionRecord(shareUID, "D" if isDirect else "I", hostUrl, str(uuid4()), displayname)
+ sharedCollectionRecord = SharedCollectionRecord(shareUID, "D" if direct else "I", hostUrl, str(uuid4()), displayname)
yield self._addOrUpdateRecord(sharedCollectionRecord)
# find in allShares, which I like better because self._allShares is a cache
share = yield self._shareForUID(shareUID, refresh=True)
# or, create fresh like legacy code
# FIXME: Need sharee home child
- # share = Share(shareeHomeChild=self._newStoreObject, sharerHomeChild=sharedCollection._newStoreObject, sharedResourceURL=hostUrl)
+ # share = Share(shareeHomeChild=self._newStoreObject, sharerHomeChild=sharedCollection._newStoreObject, url=hostUrl)
# For a direct share we will copy any calendar-color over using the owners view
color = None
- if share.isDirect() and not oldShare and sharedCollection.isCalendarCollection():
+ if share.direct() and not oldShare and sharedCollection.isCalendarCollection():
try:
color = (yield sharedCollection.readProperty(customxml.CalendarColor, request))
except HTTPError:
@@ -1253,18 +1253,18 @@
returnValue(XMLResponse(
code = responsecode.OK,
element = customxml.SharedAs(
- element.HRef.fromString(joinURL(self.url(), share.shareeResourceName()))
+ element.HRef.fromString(joinURL(self.url(), share.name()))
)
))
def removeShare(self, request, share):
""" Remove a shared collection named in resourceName """
- if share.isDirect():
+ if share.direct():
return self.removeDirectShare(request, share)
else:
# Send a decline when an invite share is removed only
- return self.declineShare(request, share.sharedResourceURL(), share.uid())
+ return self.declineShare(request, share.url(), share.uid())
@inlineCallbacks
def removeShareByUID(self, request, shareUID):
@@ -1280,7 +1280,7 @@
def removeDirectShare(self, request, share):
""" Remove a shared collection but do not send a decline back """
- shareURL = joinURL(self.url(), share.shareeResourceName())
+ shareURL = joinURL(self.url(), share.name())
if self.isCalendarCollection():
# For backwards compatibility we need to sync this up with the calendar-free-busy-set on the inbox
@@ -1413,10 +1413,10 @@
class Share(object):
- def __init__(self, sharerHomeChild, shareeHomeChild, sharedResourceURL):
+ def __init__(self, sharerHomeChild, shareeHomeChild, url):
self._shareeHomeChild = shareeHomeChild
self._sharerHomeChild = sharerHomeChild
- self._sharedResourceURL = sharedResourceURL
+ self._sharedResourceURL = url
def uid(self):
# Move to CommonHomeChild shareUID?
@@ -1425,13 +1425,13 @@
else:
return self._shareeHomeChild.shareUID()
- def isDirect(self):
+ def direct(self):
return self._shareeHomeChild.shareMode() == _BIND_MODE_DIRECT
- def sharedResourceURL(self):
+ def url(self):
return self._sharedResourceURL
- def shareeResourceName(self):
+ def name(self):
return self._shareeHomeChild.name()
def summary(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120801/a41b5b52/attachment-0001.html>
More information about the calendarserver-changes
mailing list