[CalendarServer-changes] [5731] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jun 11 14:48:01 PDT 2010
Revision: 5731
http://trac.macosforge.org/projects/calendarserver/changeset/5731
Author: cdaboo at apple.com
Date: 2010-06-11 14:47:58 -0700 (Fri, 11 Jun 2010)
Log Message:
-----------
Make sure notification resource create/delete adjusts the quota properly.
Modified Paths:
--------------
CalendarServer/trunk/twext/web2/dav/method/delete.py
CalendarServer/trunk/twistedcaldav/stdconfig.py
Added Paths:
-----------
CalendarServer/trunk/twext/web2/dav/method/delete_common.py
Modified: CalendarServer/trunk/twext/web2/dav/method/delete.py
===================================================================
--- CalendarServer/trunk/twext/web2/dav/method/delete.py 2010-06-11 21:12:32 UTC (rev 5730)
+++ CalendarServer/trunk/twext/web2/dav/method/delete.py 2010-06-11 21:47:58 UTC (rev 5731)
@@ -35,7 +35,7 @@
from twext.web2 import responsecode
from twext.web2.http import HTTPError
from twext.web2.dav import davxml
-from twext.web2.dav.fileop import delete
+from twext.web2.dav.method.delete_common import deleteResource
from twext.web2.dav.util import parentForURL
log = Logger()
@@ -62,28 +62,8 @@
yield x
x.getResult()
- # Do quota checks before we start deleting things
- myquota = waitForDeferred(self.quota(request))
- yield myquota
- myquota = myquota.getResult()
- if myquota is not None:
- old_size = waitForDeferred(self.quotaSize(request))
- yield old_size
- old_size = old_size.getResult()
- else:
- old_size = 0
-
- # Do delete
- x = waitForDeferred(delete(request.uri, self.fp, depth))
+ x = waitForDeferred(deleteResource(request, self, request.uri, depth))
yield x
- result = x.getResult()
+ yield x.getResult()
- # Adjust quota
- if myquota is not None:
- d = waitForDeferred(self.quotaSizeAdjust(request, -old_size))
- yield d
- d.getResult()
-
- yield result
-
http_DELETE = deferredGenerator(http_DELETE)
Added: CalendarServer/trunk/twext/web2/dav/method/delete_common.py
===================================================================
--- CalendarServer/trunk/twext/web2/dav/method/delete_common.py (rev 0)
+++ CalendarServer/trunk/twext/web2/dav/method/delete_common.py 2010-06-11 21:47:58 UTC (rev 5731)
@@ -0,0 +1,72 @@
+# -*- test-case-name: twext.web2.dav.test.test_delete -*-
+##
+# Copyright (c) 2005-2010 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.
+##
+
+"""
+WebDAV DELETE method
+"""
+
+__all__ = ["deleteResource"]
+
+from twisted.internet.defer import waitForDeferred, deferredGenerator
+
+from twext.python.log import Logger
+from twext.web2 import responsecode
+from twext.web2.http import HTTPError
+from twext.web2.dav.fileop import delete
+
+log = Logger()
+
+
+def deleteResource(request, resource, resource_uri, depth="0"):
+ """
+ Handle a resource delete with proper quota etc updates
+ """
+ if not resource.fp.exists():
+ log.err("File not found: %s" % (resource.fp.path,))
+ raise HTTPError(responsecode.NOT_FOUND)
+
+ # Do quota checks before we start deleting things
+ myquota = waitForDeferred(resource.quota(request))
+ yield myquota
+ myquota = myquota.getResult()
+ if myquota is not None:
+ old_size = waitForDeferred(resource.quotaSize(request))
+ yield old_size
+ old_size = old_size.getResult()
+ else:
+ old_size = 0
+
+ # Do delete
+ x = waitForDeferred(delete(resource_uri, resource.fp, depth))
+ yield x
+ result = x.getResult()
+
+ # Adjust quota
+ if myquota is not None:
+ d = waitForDeferred(resource.quotaSizeAdjust(request, -old_size))
+ yield d
+ d.getResult()
+
+ yield result
+
+deleteResource = deferredGenerator(deleteResource)
Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py 2010-06-11 21:12:32 UTC (rev 5730)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py 2010-06-11 21:47:58 UTC (rev 5731)
@@ -338,7 +338,6 @@
"Calendars" : {
"Enabled" : True, # Calendar on/off switch
- "AllowScheduling" : False, # Scheduling in shared calendars
},
"AddressBooks" : {
"Enabled" : True, # Address Books on/off switch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100611/4dc8f7be/attachment.html>
More information about the calendarserver-changes
mailing list