[CalendarServer-changes] [370]
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Fri Nov 3 17:56:41 PST 2006
Revision: 370
http://trac.macosforge.org/projects/calendarserver/changeset/370
Author: cdaboo at apple.com
Date: 2006-11-03 17:56:40 -0800 (Fri, 03 Nov 2006)
Log Message:
-----------
New methods for subscribe/unsubscribe of notifications. The names on these will be changing soon.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/__init__.py
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/delete.py
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/put.py
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/notifications.py
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/repository.py
Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py 2006-11-04 01:01:00 UTC (rev 369)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py 2006-11-04 01:56:40 UTC (rev 370)
@@ -138,10 +138,10 @@
(twisted_dav_namespace, "action" ): (1, 1),
(twisted_dav_namespace, "time-stamp" ): (1, 1),
(twisted_dav_namespace, "auth-id" ): (0, 1),
+ (twisted_dav_namespace, "old-uri" ): (0, 1),
+ (twisted_dav_namespace, "new-uri" ): (0, 1),
(twisted_dav_namespace, "old-etag" ): (0, 1),
(twisted_dav_namespace, "new-etag" ): (0, 1),
- (twisted_dav_namespace, "old-uri" ): (0, 1),
- (twisted_dav_namespace, "new_uri" ): (0, 1),
}
class Action (davxml.WebDAVElement):
@@ -240,26 +240,6 @@
hidden = True
protected = True
-class OldETag (davxml.WebDAVTextElement):
- """
- A property to indicate the old ETag of a notification resource.
- (Apple Extension to CalDAV)
- """
- namespace = twisted_dav_namespace
- name = "old-etag"
- hidden = True
- protected = True
-
-class NewETag (davxml.WebDAVTextElement):
- """
- A property to indicate the new ETag of a notification resource.
- (Apple Extension to CalDAV)
- """
- namespace = twisted_dav_namespace
- name = "new-etag"
- hidden = True
- protected = True
-
class OldURI (davxml.WebDAVElement):
"""
A property to indicate the old URI of a notification resource.
@@ -284,25 +264,35 @@
allowed_children = { (davxml.dav_namespace, "href"): (0, 1) }
-class AutoSubscribed (davxml.WebDAVElement):
+class OldETag (davxml.WebDAVTextElement):
"""
- A property to indicate which principals will receive notifications.
+ A property to indicate the old ETag of a notification resource.
(Apple Extension to CalDAV)
"""
namespace = twisted_dav_namespace
- name = "auto-subscribed"
+ name = "old-etag"
hidden = True
+ protected = True
- allowed_children = { (davxml.dav_namespace, "principal"): (0, None) }
+class NewETag (davxml.WebDAVTextElement):
+ """
+ A property to indicate the new ETag of a notification resource.
+ (Apple Extension to CalDAV)
+ """
+ namespace = twisted_dav_namespace
+ name = "new-etag"
+ hidden = True
+ protected = True
-class Unsubscribed (davxml.WebDAVElement):
+class Subscribed (davxml.WebDAVElement):
"""
- A property to indicate which auto-subscribed principals will not receive notifications.
+ A property to indicate which principals will receive notifications.
(Apple Extension to CalDAV)
"""
namespace = twisted_dav_namespace
- name = "unsubscribed"
+ name = "subscribed"
hidden = True
+ protected = True
allowed_children = { (davxml.dav_namespace, "principal"): (0, None) }
Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/__init__.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/__init__.py 2006-11-04 01:01:00 UTC (rev 369)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/__init__.py 2006-11-04 01:56:40 UTC (rev 370)
@@ -36,4 +36,6 @@
"report_multiget",
"report_freebusy",
"schedule_common",
+ "x_twisted_subscribe",
+ "x_twisted_unsubscribe",
]
Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/delete.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/delete.py 2006-11-04 01:01:00 UTC (rev 369)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/delete.py 2006-11-04 01:56:40 UTC (rev 370)
@@ -66,7 +66,7 @@
if isinstance(request.authnUser.children[0], davxml.HRef):
authid = str(request.authnUser.children[0])
- notification = Notification(action=Notification.ACTION_DELETED, authid=authid, oldETag=oldETag, oldURI=request.uri)
+ notification = Notification(action=Notification.ACTION_DELETED, authid=authid, oldURI=request.uri, oldETag=oldETag)
d = waitForDeferred(notification.doNotification(request, parent, self))
yield d
d.getResult()
Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/put.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/put.py 2006-11-04 01:01:00 UTC (rev 369)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/put.py 2006-11-04 01:56:40 UTC (rev 370)
@@ -110,11 +110,18 @@
else:
newETag = None
+ if response.code == responsecode.CREATED:
+ oldURI = None
+ newURI = request.uri
+ else:
+ oldURI = request.uri
+ newURI = None
+
notification = Notification(action={
responsecode.OK : Notification.ACTION_MODIFIED,
responsecode.CREATED : Notification.ACTION_CREATED,
responsecode.NO_CONTENT : Notification.ACTION_MODIFIED,
- }[response.code], authid=authid, oldETag=oldETag, newETag=newETag, oldURI=request.uri)
+ }[response.code], authid=authid, oldURI=oldURI, newURI=newURI, oldETag=oldETag, newETag=newETag)
d = waitForDeferred(notification.doNotification(request, parent, self))
yield d
d.getResult()
Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/notifications.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/notifications.py 2006-11-04 01:01:00 UTC (rev 369)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/notifications.py 2006-11-04 01:56:40 UTC (rev 370)
@@ -112,25 +112,18 @@
_expandPrincipals = deferredGenerator(_expandPrincipals)
# For drop box we look at the parent collection of the target resource and get the
- # set of auto-subscribed principals, then subtract the set of unsubscribed principals.
- if not parent.hasDeadProperty(customxml.AutoSubscribed):
+ # set of subscribed principals.
+ if not parent.hasDeadProperty(customxml.Subscribed):
yield None
return
principals = set()
- autosubs = parent.readDeadProperty(customxml.AutoSubscribed).children
+ autosubs = parent.readDeadProperty(customxml.Subscribed).children
d = waitForDeferred(_expandPrincipals(autosubs))
yield d
autosubs = d.getResult()
principals.update(autosubs)
- if parent.hasDeadProperty(customxml.Unsubscribed):
- unsubs = parent.readDeadProperty(customxml.Unsubscribed).children
- d = waitForDeferred(_expandPrincipals(unsubs))
- yield d
- unsubs = d.getResult()
- principals.difference_update(unsubs)
-
for principal in principals:
if not isinstance(principal.children[0], davxml.HRef):
continue
@@ -152,7 +145,7 @@
# Create new resource in the collection
child = NotificationFile(path=path)
collection.putChild(name, child)
- d = waitForDeferred(request.locateChildResource(collection, name)) # This ensure the URI for the resource is mapped
+ d = waitForDeferred(request.locateChildResource(collection, name)) # This ensures the URI for the resource is mapped
yield d
child = d.getResult()
@@ -172,10 +165,10 @@
(twisted_dav_namespace, "action" ),
(twisted_dav_namespace, "time-stamp" ),
(twisted_dav_namespace, "auth-id" ),
- (twisted_dav_namespace, "old-etag" ),
- (twisted_dav_namespace, "new-etag" ),
(twisted_dav_namespace, "old-uri" ),
(twisted_dav_namespace, "new-uri" ),
+ (twisted_dav_namespace, "old-etag" ),
+ (twisted_dav_namespace, "new-etag" ),
)
class NotificationFile(DAVResource, DAVFile):
@@ -205,14 +198,14 @@
elements.append(customxml.TimeStamp.fromString(notification.timestamp))
if notification.authid:
elements.append(customxml.AuthID.fromString(notification.authid))
- if notification.oldETag:
- elements.append(customxml.OldETag.fromString(notification.oldETag))
- if notification.newETag:
- elements.append(customxml.NewETag.fromString(notification.newETag))
if notification.oldURI:
elements.append(customxml.OldURI(davxml.HRef.fromString(notification.oldURI)))
if notification.newURI:
elements.append(customxml.NewURI(davxml.HRef.fromString(notification.newURI)))
+ if notification.oldETag:
+ elements.append(customxml.OldETag.fromString(notification.oldETag))
+ if notification.newETag:
+ elements.append(customxml.NewETag.fromString(notification.newETag))
xml = customxml.Notification(*elements)
Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/repository.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/repository.py 2006-11-04 01:01:00 UTC (rev 369)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/repository.py 2006-11-04 01:56:40 UTC (rev 370)
@@ -705,9 +705,9 @@
)
# Check for proper account home
- if not self.accountCollection:
- log.err("Accounts cannot be created: no principal collection was marked with an account attribute.")
- raise ValueError, "Accounts cannot be created."
+ #if not self.accountCollection:
+ # log.err("Accounts cannot be created: no principal collection was marked with an account attribute.")
+ # raise ValueError, "Accounts cannot be created."
# Provision each user
for repeat, principal in self.items:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061103/d3d4fabd/attachment.html
More information about the calendarserver-changes
mailing list