[CalendarServer-changes] [450]
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Mon Nov 13 20:01:49 PST 2006
Revision: 450
http://trac.macosforge.org/projects/calendarserver/changeset/450
Author: cdaboo at apple.com
Date: 2006-11-13 20:01:49 -0800 (Mon, 13 Nov 2006)
Log Message:
-----------
Simplified notification resource data.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.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
Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py 2006-11-14 03:54:48 UTC (rev 449)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/customxml.py 2006-11-14 04:01:49 UTC (rev 450)
@@ -137,91 +137,10 @@
name = "notification"
allowed_children = {
- (apple_namespace, "action" ): (1, 1),
(apple_namespace, "time-stamp" ): (1, 1),
- (apple_namespace, "auth-id" ): (0, 1),
- (apple_namespace, "old-uri" ): (0, 1),
- (apple_namespace, "new-uri" ): (0, 1),
- (apple_namespace, "old-etag" ): (0, 1),
- (apple_namespace, "new-etag" ): (0, 1),
+ (apple_namespace, "changed" ): (1, 1),
}
-class Action (davxml.WebDAVElement):
- """
- A property to indicate the action of a notification resource.
- (Apple Extension to CalDAV)
- """
- namespace = apple_namespace
- name = "action"
- hidden = True
- protected = True
-
- allowed_children = {
- (apple_namespace, "created" ): (0, 1),
- (apple_namespace, "modified" ): (0, 1),
- (apple_namespace, "deleted" ): (0, 1),
- (apple_namespace, "copiedto" ): (0, 1),
- (apple_namespace, "copiedfrom" ): (0, 1),
- (apple_namespace, "movedout" ): (0, 1),
- (apple_namespace, "movedin" ): (0, 1),
- }
-
-class Created (davxml.WebDAVEmptyElement):
- """
- A property value to indicate the created action of a notification resource.
- (Apple Extension to CalDAV)
- """
- namespace = apple_namespace
- name = "created"
-
-class Modified (davxml.WebDAVEmptyElement):
- """
- A property value to indicate the modified action of a notification resource.
- (Apple Extension to CalDAV)
- """
- namespace = apple_namespace
- name = "modified"
-
-class Deleted (davxml.WebDAVEmptyElement):
- """
- A property value to indicate the deleted action of a notification resource.
- (Apple Extension to CalDAV)
- """
- namespace = apple_namespace
- name = "deleted"
-
-class CopiedTo (davxml.WebDAVEmptyElement):
- """
- A property value to indicate the copied to action of a notification resource.
- (Apple Extension to CalDAV)
- """
- namespace = apple_namespace
- name = "copiedto"
-
-class CopiedFrom (davxml.WebDAVEmptyElement):
- """
- A property value to indicate the copied from action of a notification resource.
- (Apple Extension to CalDAV)
- """
- namespace = apple_namespace
- name = "copiedfrom"
-
-class MovedTo (davxml.WebDAVEmptyElement):
- """
- A property value to indicate the moved to action of a notification resource.
- (Apple Extension to CalDAV)
- """
- namespace = apple_namespace
- name = "movedto"
-
-class MovedFrom (davxml.WebDAVEmptyElement):
- """
- A property value to indicate the moved from action of a notification resource.
- (Apple Extension to CalDAV)
- """
- namespace = apple_namespace
- name = "movedfrom"
-
class TimeStamp (davxml.WebDAVTextElement):
"""
A property to indicate the timestamp of a notification resource.
@@ -232,60 +151,19 @@
hidden = True
protected = True
-class AuthID (davxml.WebDAVTextElement):
+class Changed (davxml.WebDAVElement):
"""
- A property to indicate the authorization identitifer of a notification resource.
+ A property to indicate the URI of the drop box that generated
+ notification resource.
(Apple Extension to CalDAV)
"""
namespace = apple_namespace
- name = "auth-id"
+ name = "changed"
hidden = True
protected = True
-class OldURI (davxml.WebDAVElement):
- """
- A property to indicate the old URI of a notification resource.
- (Apple Extension to CalDAV)
- """
- namespace = apple_namespace
- name = "old-uri"
- hidden = True
- protected = True
-
allowed_children = { (davxml.dav_namespace, "href"): (0, 1) }
-class NewURI (davxml.WebDAVElement):
- """
- A property to indicate the new URI of a notification resource.
- (Apple Extension to CalDAV)
- """
- namespace = apple_namespace
- name = "new-uri"
- hidden = True
- protected = True
-
- allowed_children = { (davxml.dav_namespace, "href"): (0, 1) }
-
-class OldETag (davxml.WebDAVTextElement):
- """
- A property to indicate the old ETag of a notification resource.
- (Apple Extension to CalDAV)
- """
- namespace = apple_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 = apple_namespace
- name = "new-etag"
- hidden = True
- protected = True
-
class Subscribed (davxml.WebDAVElement):
"""
A property to indicate which principals will receive notifications.
Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/delete.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/delete.py 2006-11-14 03:54:48 UTC (rev 449)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/delete.py 2006-11-14 04:01:49 UTC (rev 450)
@@ -41,17 +41,11 @@
# Also handle notifications in a drop box collection.
#
- parent = waitForDeferred(request.locateResource(parentForURL(request.uri)))
+ parentURL = parentForURL(request.uri)
+ parent = waitForDeferred(request.locateResource(parentURL))
yield parent
parent = parent.getResult()
- # May need old etag for notification
- if DropBox.enabled and parent.isSpecialCollection(customxml.DropBox):
- if self.exists() and self.etag() is not None:
- oldETag = self.etag().generate()
- else:
- oldETag = None
-
d = waitForDeferred(super(CalDAVFile, self).http_DELETE(request))
yield d
response = d.getResult()
@@ -62,12 +56,8 @@
index.deleteResource(self.fp.basename())
elif DropBox.enabled and parent.isSpecialCollection(customxml.DropBox):
# We need to handle notificiations
- authid = None
- if isinstance(request.authnUser.children[0], davxml.HRef):
- authid = str(request.authnUser.children[0])
-
- notification = Notification(action=Notification.ACTION_DELETED, authid=authid, oldURI=request.uri, oldETag=oldETag)
- d = waitForDeferred(notification.doNotification(request, parent, self))
+ notification = Notification(parentURL=parentURL)
+ d = waitForDeferred(notification.doNotification(request, parent))
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-14 03:54:48 UTC (rev 449)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/method/put.py 2006-11-14 04:01:49 UTC (rev 450)
@@ -25,7 +25,6 @@
from twisted.internet.defer import deferredGenerator, waitForDeferred
from twisted.python import log
from twisted.web2 import responsecode
-from twisted.web2.dav import davxml
from twisted.web2.dav.element.base import twisted_dav_namespace
from twisted.web2.dav.http import ErrorResponse
from twisted.web2.dav.util import allDataFromStream, parentForURL
@@ -40,7 +39,8 @@
def http_PUT(self, request):
- parent = waitForDeferred(request.locateResource(parentForURL(request.uri)))
+ parentURL = parentForURL(request.uri)
+ parent = waitForDeferred(request.locateResource(parentURL))
yield parent
parent = parent.getResult()
@@ -88,41 +88,14 @@
elif DropBox.enabled and parent.isSpecialCollection(customxml.DropBox):
# We need to handle notificiations
- # We need the current etag
- if self.exists() and self.etag() is not None:
- oldETag = self.etag().generate()
- else:
- oldETag = None
-
# Do the normal http_PUT behavior
d = waitForDeferred(super(CalDAVFile, self).http_PUT(request))
yield d
response = d.getResult()
if response.code in (responsecode.OK, responsecode.CREATED, responsecode.NO_CONTENT):
-
- authid = None
- if isinstance(request.authnUser.children[0], davxml.HRef):
- authid = str(request.authnUser.children[0])
-
- if self.exists() and self.etag() is not None:
- newETag = self.etag().generate()
- 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, oldURI=oldURI, newURI=newURI, oldETag=oldETag, newETag=newETag)
- d = waitForDeferred(notification.doNotification(request, parent, self))
+ notification = Notification(parentURL=parentURL)
+ d = waitForDeferred(notification.doNotification(request, parent))
yield d
d.getResult()
Modified: CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/notifications.py
===================================================================
--- CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/notifications.py 2006-11-14 03:54:48 UTC (rev 449)
+++ CalendarServer/branches/users/cdaboo/dropbox/twistedcaldav/notifications.py 2006-11-14 04:01:49 UTC (rev 450)
@@ -48,30 +48,16 @@
Encapsulates a notification message.
"""
- ACTION_NONE = 0
- ACTION_CREATED = 1
- ACTION_MODIFIED = 2
- ACTION_DELETED = 3
- ACTION_COPIED_TO = 4
- ACTION_COPIED_FROM = 5
- ACTION_MOVED_TO = 6
- ACTION_MOVED_FROM = 7
-
- def __init__(self, action, authid=None, oldETag=None, newETag=None, oldURI=None, newURI=None):
- self.action = action
+ def __init__(self, parentURL):
self.timestamp = datetime.datetime.utcnow()
- self.authid = authid
- self.oldETag = oldETag
- self.newETag = newETag
- self.oldURI = oldURI
- self.newURI = newURI
+ self.parentURL = parentURL
- def doNotification(self, request, parent, resource):
+ def doNotification(self, request, parent):
"""
Put the supplied noitification into the notification collection of the specified principal.
@param request: L{Request} for request in progress.
- @param resource: L{DAVResource}trigerring the notification.
+ @param parent: L{DAVResource} for parent of resource trigerring the notification.
"""
# First determine which principals should get notified
@@ -164,13 +150,8 @@
"""
liveProperties = DAVResource.liveProperties + (
- (apple_namespace, "action" ),
(apple_namespace, "time-stamp" ),
- (apple_namespace, "auth-id" ),
- (apple_namespace, "old-uri" ),
- (apple_namespace, "new-uri" ),
- (apple_namespace, "old-etag" ),
- (apple_namespace, "new-etag" ),
+ (apple_namespace, "changed" ),
)
class NotificationFile(DAVResource, DAVFile):
@@ -185,29 +166,8 @@
# Create body XML
elements = []
- elements.append(customxml.Action(
- {
- Notification.ACTION_CREATED: customxml.Created(),
- Notification.ACTION_MODIFIED: customxml.Modified(),
- Notification.ACTION_DELETED: customxml.Deleted(),
- Notification.ACTION_COPIED_TO: customxml.CopiedTo(),
- Notification.ACTION_COPIED_FROM: customxml.CopiedFrom(),
- Notification.ACTION_MOVED_TO: customxml.MovedTo(),
- Notification.ACTION_MOVED_FROM: customxml.MovedFrom(),
- }[notification.action]
- ))
-
elements.append(customxml.TimeStamp.fromString(notification.timestamp))
- if notification.authid:
- elements.append(customxml.AuthID.fromString(notification.authid))
- 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))
+ elements.append(customxml.Changed(davxml.HRef.fromString(notification.parentURL)))
xml = customxml.Notification(*elements)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061113/c98a4d5a/attachment.html
More information about the calendarserver-changes
mailing list