[CalendarServer-changes] [6805] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jan 25 13:50:04 PST 2011
Revision: 6805
http://trac.macosforge.org/projects/calendarserver/changeset/6805
Author: wsanchez at apple.com
Date: 2011-01-25 13:50:03 -0800 (Tue, 25 Jan 2011)
Log Message:
-----------
cosmetic
Modified Paths:
--------------
CalendarServer/trunk/twext/web2/dav/method/put_common.py
CalendarServer/trunk/twistedcaldav/freebusyurl.py
CalendarServer/trunk/twistedcaldav/method/copymove.py
CalendarServer/trunk/twistedcaldav/method/copymove_contact.py
CalendarServer/trunk/twistedcaldav/method/get.py
CalendarServer/trunk/twistedcaldav/method/mkcalendar.py
CalendarServer/trunk/twistedcaldav/method/mkcol.py
CalendarServer/trunk/twistedcaldav/method/post.py
CalendarServer/trunk/twistedcaldav/method/put.py
CalendarServer/trunk/twistedcaldav/method/report_addressbook_query.py
CalendarServer/trunk/twistedcaldav/method/report_calendar_query.py
CalendarServer/trunk/twistedcaldav/method/report_sync_collection.py
CalendarServer/trunk/twistedcaldav/scheduling/caldav.py
CalendarServer/trunk/twistedcaldav/scheduling/imip.py
CalendarServer/trunk/twistedcaldav/scheduling/implicit.py
CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py
CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py
CalendarServer/trunk/twistedcaldav/sharing.py
CalendarServer/trunk/twistedcaldav/storebridge.py
CalendarServer/trunk/twistedcaldav/timezoneservice.py
Modified: CalendarServer/trunk/twext/web2/dav/method/put_common.py
===================================================================
--- CalendarServer/trunk/twext/web2/dav/method/put_common.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twext/web2/dav/method/put_common.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -234,7 +234,10 @@
diff_size = new_dest_size - old_dest_size
if diff_size >= destquota[0]:
log.err("Over quota: available %d, need %d" % (destquota[0], diff_size))
- raise HTTPError(ErrorResponse(responsecode.INSUFFICIENT_STORAGE_SPACE, (dav_namespace, "quota-not-exceeded")))
+ raise HTTPError(ErrorResponse(
+ responsecode.INSUFFICIENT_STORAGE_SPACE,
+ (dav_namespace, "quota-not-excee")
+ ))
d = waitForDeferred(destination.quotaSizeAdjust(request, diff_size))
yield d
d.getResult()
Modified: CalendarServer/trunk/twistedcaldav/freebusyurl.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/freebusyurl.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/freebusyurl.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -160,13 +160,19 @@
# Some things we do not handle
if self.token or self.user:
- raise HTTPError(ErrorResponse(responsecode.NOT_ACCEPTABLE, (calendarserver_namespace, "supported-query-parameter")))
+ raise HTTPError(ErrorResponse(
+ responsecode.NOT_ACCEPTABLE,
+ (calendarserver_namespace, "supported-query-parameter")
+ ))
# Check format
if self.format:
self.format = self.format.split(";")[0]
if self.format not in ("text/calendar", "text/plain"):
- raise HTTPError(ErrorResponse(responsecode.NOT_ACCEPTABLE, (calendarserver_namespace, "supported-format")))
+ raise HTTPError(ErrorResponse(
+ responsecode.NOT_ACCEPTABLE,
+ (calendarserver_namespace, "supported-format")
+ ))
else:
self.format = "text/calendar"
@@ -183,17 +189,26 @@
if self.duration:
self.duration = parse_duration(self.duration)
except ValueError:
- raise HTTPError(ErrorResponse(responsecode.BAD_REQUEST, (calendarserver_namespace, "valid-query-parameters")))
+ raise HTTPError(ErrorResponse(
+ responsecode.BAD_REQUEST,
+ (calendarserver_namespace, "valid-query-parameters")
+ ))
# Sanity check start/end/duration
# End and duration cannot both be present
if self.end and self.duration:
- raise HTTPError(ErrorResponse(responsecode.NOT_ACCEPTABLE, (calendarserver_namespace, "valid-query-parameters")))
+ raise HTTPError(ErrorResponse(
+ responsecode.NOT_ACCEPTABLE,
+ (calendarserver_namespace, "valid-query-parameters")
+ ))
# Duration must be positive
if self.duration and self.duration.days < 0:
- raise HTTPError(ErrorResponse(responsecode.BAD_REQUEST, (calendarserver_namespace, "valid-query-parameters")))
+ raise HTTPError(ErrorResponse(
+ responsecode.BAD_REQUEST,
+ (calendarserver_namespace, "valid-query-parameters")
+ ))
# Now fill in the missing pieces
if self.start is None:
@@ -206,7 +221,10 @@
# End > start
if self.end <= self.start:
- raise HTTPError(ErrorResponse(responsecode.BAD_REQUEST, (calendarserver_namespace, "valid-query-parameters")))
+ raise HTTPError(ErrorResponse(
+ responsecode.BAD_REQUEST,
+ (calendarserver_namespace, "valid-query-parameters")
+ ))
# TODO: We should probably verify that the actual time-range is within sensible bounds (e.g. not too far in the past or future and not too long)
Modified: CalendarServer/trunk/twistedcaldav/method/copymove.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/copymove.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/method/copymove.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -88,7 +88,10 @@
# Checks for copying a calendar collection
if self.isCalendarCollection():
log.err("Attempt to copy a calendar collection into another calendar collection %s" % destination)
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "calendar-collection-location-ok")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "calendar-collection-location-ok")
+ ))
# We also do not allow regular collections in calendar collections
if self.isCollection():
@@ -168,7 +171,10 @@
# Checks for copying a calendar collection
if self.isCalendarCollection():
log.err("Attempt to move a calendar collection into another calendar collection %s" % destination)
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "calendar-collection-location-ok")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "calendar-collection-location-ok")
+ ))
# We also do not allow regular collections in calendar collections
if self.isCollection():
Modified: CalendarServer/trunk/twistedcaldav/method/copymove_contact.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/copymove_contact.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/method/copymove_contact.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -81,7 +81,10 @@
# Checks for copying an addressbook collection
if self.isAddressBookCollection():
log.err("Attempt to copy an addressbook collection into another addressbook collection %s" % destination)
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (carddav_namespace, "addressbook-collection-location-ok")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (carddav_namespace, "addressbook-collection-location-ok")
+ ))
# We also do not allow regular collections in addressbook collections
if self.isCollection():
@@ -148,7 +151,10 @@
# Checks for copying an addressbook collection
if self.isAddressBookCollection():
log.err("Attempt to move an addressbook collection into another addressbook collection %s" % destination)
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (carddav_namespace, "addressbook-collection-location-ok")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (carddav_namespace, "addressbook-collection-location-ok")
+ ))
# We also do not allow regular collections in addressbook collections
if self.isCollection():
Modified: CalendarServer/trunk/twistedcaldav/method/get.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/get.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/method/get.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -46,7 +46,10 @@
if request.args:
action = request.args.get("action", ("",))
if len(action) != 1:
- raise HTTPError(ErrorResponse(responsecode.BAD_REQUEST, (calendarserver_namespace, "valid-action")))
+ raise HTTPError(ErrorResponse(
+ responsecode.BAD_REQUEST,
+ (calendarserver_namespace, "valid-action")
+ ))
action = action[0]
dispatch = {
@@ -54,7 +57,10 @@
}.get(action, None)
if dispatch is None:
- raise HTTPError(ErrorResponse(responsecode.BAD_REQUEST, (calendarserver_namespace, "supported-action")))
+ raise HTTPError(ErrorResponse(
+ responsecode.BAD_REQUEST,
+ (calendarserver_namespace, "supported-action")
+ ))
response = (yield dispatch(request))
returnValue(response)
Modified: CalendarServer/trunk/twistedcaldav/method/mkcalendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/mkcalendar.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/method/mkcalendar.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -53,16 +53,16 @@
log.err("Attempt to create collection where resource exists: %s" % (self,))
raise HTTPError(ErrorResponse(
responsecode.FORBIDDEN,
- (davxml.dav_namespace, "resource-must-be-null"))
- )
+ (davxml.dav_namespace, "resource-must-be-null")
+ ))
if not parent.isCollection():
log.err("Attempt to create collection with non-collection parent: %s"
% (self,))
raise HTTPError(ErrorResponse(
responsecode.CONFLICT,
- (caldavxml.caldav_namespace, "calendar-collection-location-ok"))
- )
+ (caldavxml.caldav_namespace, "calendar-collection-location-ok")
+ ))
#
# Read request body
Modified: CalendarServer/trunk/twistedcaldav/method/mkcol.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/mkcol.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/method/mkcol.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -58,16 +58,16 @@
% (self,))
raise HTTPError(ErrorResponse(
responsecode.FORBIDDEN,
- (davxml.dav_namespace, "resource-must-be-null"))
- )
+ (davxml.dav_namespace, "resource-must-be-null")
+ ))
if not parent.isCollection():
log.err("Attempt to create collection with non-collection parent: %s"
% (self,))
raise HTTPError(ErrorResponse(
responsecode.CONFLICT,
- (davxml.dav_namespace, "collection-location-ok"))
- )
+ (davxml.dav_namespace, "collection-location-ok")
+ ))
#
# Don't allow DAV collections in a calendar or address book collection
Modified: CalendarServer/trunk/twistedcaldav/method/post.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/post.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/method/post.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -75,7 +75,10 @@
content_type = request.headers.getHeader("content-type")
if content_type is not None and (content_type.mediaType, content_type.mediaSubtype) != ("text", "calendar"):
self.log_error("MIME type %s not allowed in calendar collection" % (content_type,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "supported-calendar-data")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "supported-calendar-data")
+ ))
# Read the calendar component from the stream
try:
@@ -87,7 +90,11 @@
# We must have some data at this point
if calendardata is None:
# Use correct DAV:error response
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description="No calendar data"))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-calendar-data"),
+ description="No calendar data"
+ ))
# Create a new name if one was not provided
name = md5(str(calendardata) + str(time.time()) + request.path).hexdigest() + ".ics"
@@ -124,7 +131,10 @@
content_type = request.headers.getHeader("content-type")
if content_type is not None and (content_type.mediaType, content_type.mediaSubtype) != ("text", "vcard"):
self.log_error("MIME type %s not allowed in address book collection" % (content_type,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (carddav_namespace, "supported-address-data")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (carddav_namespace, "supported-address-data")
+ ))
# Read the calendar component from the stream
try:
@@ -136,7 +146,11 @@
# We must have some data at this point
if vcarddata is None:
# Use correct DAV:error response
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (carddav_namespace, "valid-address-data"), description="No address data"))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (carddav_namespace, "valid-address-data"),
+ description="No address data"
+ ))
# Create a new name if one was not provided
name = md5(str(vcarddata) + str(time.time()) + request.path).hexdigest() + ".vcf"
Modified: CalendarServer/trunk/twistedcaldav/method/put.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/put.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/method/put.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -52,7 +52,10 @@
content_type = request.headers.getHeader("content-type")
if content_type is not None and (content_type.mediaType, content_type.mediaSubtype) != ("text", "calendar"):
log.err("MIME type %s not allowed in calendar collection" % (content_type,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "supported-calendar-data")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "supported-calendar-data")
+ ))
# Read the calendar component from the stream
try:
@@ -64,7 +67,11 @@
# We must have some data at this point
if calendardata is None:
# Use correct DAV:error response
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description="No calendar data"))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-calendar-data"),
+ description="No calendar data"
+ ))
storer = StoreCalendarObjectResource(
request = request,
@@ -87,7 +94,10 @@
content_type = request.headers.getHeader("content-type")
if content_type is not None and (content_type.mediaType, content_type.mediaSubtype) != ("text", "vcard"):
log.err("MIME type %s not allowed in address book collection" % (content_type,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (carddav_namespace, "supported-address-data")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (carddav_namespace, "supported-address-data")
+ ))
# Read the vcard component from the stream
try:
@@ -99,7 +109,11 @@
# We must have some data at this point
if vcarddata is None:
# Use correct DAV:error response
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (carddav_namespace, "valid-address-data"), description="No vcard data"))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (carddav_namespace, "valid-address-data"),
+ description="No vcard data"
+ ))
storer = StoreAddressObjectResource(
request = request,
Modified: CalendarServer/trunk/twistedcaldav/method/report_addressbook_query.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/report_addressbook_query.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/method/report_addressbook_query.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -81,7 +81,10 @@
result, message, generate_address_data = report_common.validPropertyListAddressDataTypeVersion(query)
if not result:
log.err(message)
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (carddav_namespace, "supported-address-data")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (carddav_namespace, "supported-address-data")
+ ))
else:
raise AssertionError("We shouldn't be here")
@@ -89,7 +92,10 @@
# Verify that the filter element is valid
if (filter is None) or not filter.valid():
log.err("Invalid filter element: %r" % (filter,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (carddav_namespace, "valid-filter")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (carddav_namespace, "valid-filter")
+ ))
matchcount = [0,]
max_number_of_results = [config.MaxQueryWithDataResults if generate_address_data else None,]
Modified: CalendarServer/trunk/twistedcaldav/method/report_calendar_query.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/report_calendar_query.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/method/report_calendar_query.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -74,7 +74,10 @@
if query_tz is not None and not query_tz.valid():
msg = "CalDAV:timezone must contain one VTIMEZONE component only: %s" % (query_tz,)
log.err(msg)
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description=msg))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-calendar-data"), description=msg
+ ))
if query_tz:
filter.settimezone(query_tz)
query_timezone = tuple(calendar_query.timezone.calendar().subcomponents())[0]
@@ -94,7 +97,10 @@
result, message, generate_calendar_data = report_common.validPropertyListCalendarDataTypeVersion(props)
if not result:
log.err(message)
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "supported-calendar-data")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "supported-calendar-data")
+ ))
else:
raise AssertionError("We shouldn't be here")
@@ -102,7 +108,10 @@
# Verify that the filter element is valid
if (filter is None) or not filter.valid():
log.err("Invalid filter element: %r" % (xmlfilter,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-filter")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-filter")
+ ))
matchcount = [0]
max_number_of_results = [config.MaxQueryWithDataResults if generate_calendar_data else None,]
@@ -232,11 +241,14 @@
log.err("Too many instances need to be computed in calendar-query report")
raise HTTPError(ErrorResponse(
responsecode.FORBIDDEN,
- NumberOfRecurrencesWithinLimits(PCDATAElement(str(ex.max_allowed)))
- ))
+ NumberOfRecurrencesWithinLimits(PCDATAElement(str(ex.max_allowed)))
+ ))
except NumberOfMatchesWithinLimits:
log.err("Too many matching components in calendar-query report")
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, davxml.NumberOfMatchesWithinLimits()))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ davxml.NumberOfMatchesWithinLimits()
+ ))
if not hasattr(request, "extendedLogItems"):
request.extendedLogItems = {}
Modified: CalendarServer/trunk/twistedcaldav/method/report_sync_collection.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/report_sync_collection.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/method/report_sync_collection.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -51,7 +51,10 @@
# These resource support the report
if not config.EnableSyncReport or davxml.Report(SyncCollection(),) not in self.supportedReports():
log.err("sync-collection report is only allowed on calendar/inbox/addressbook/notification collection resources %s" % (self,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, davxml.SupportedReport()))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ davxml.SupportedReport()
+ ))
responses = []
Modified: CalendarServer/trunk/twistedcaldav/scheduling/caldav.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/caldav.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/scheduling/caldav.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -112,8 +112,15 @@
yield recipient.inbox.checkPrivileges(self.scheduler.request, (caldavxml.ScheduleDeliver(),), principal=organizerPrincipal)
except AccessDeniedError:
log.err("Could not access Inbox for recipient: %s" % (recipient.cuaddr,))
- err = HTTPError(ErrorResponse(responsecode.NOT_FOUND, (caldav_namespace, "recipient-permissions")))
- self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.NO_AUTHORITY)
+ err = HTTPError(ErrorResponse(
+ responsecode.NOT_FOUND,
+ (caldav_namespace, "recipient-permissions")
+ ))
+ self.responses.add(
+ recipient.cuaddr,
+ Failure(exc_value=err),
+ reqstatus=iTIPRequestStatus.NO_AUTHORITY
+ )
# Process next recipient
continue
@@ -150,7 +157,10 @@
))
except ImplicitProcessorException, e:
log.err("Could not store data in Inbox : %s" % (recipient.inbox,))
- err = HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "recipient-permissions")))
+ err = HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "recipient-permissions")
+ ))
responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=e.msg)
returnValue(False)
@@ -178,7 +188,10 @@
except:
# FIXME: Bare except
log.err("Could not store data in Inbox : %s" % (recipient.inbox,))
- err = HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "recipient-permissions")))
+ err = HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "recipient-permissions")
+ ))
responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.NO_AUTHORITY)
returnValue(False)
else:
@@ -216,11 +229,23 @@
))
except:
log.err("Could not determine free busy information: %s" % (recipient.cuaddr,))
- err = HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "recipient-permissions")))
- responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.NO_AUTHORITY)
+ err = HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "recipient-permissions")
+ ))
+ responses.add(
+ recipient.cuaddr,
+ Failure(exc_value=err),
+ reqstatus=iTIPRequestStatus.NO_AUTHORITY
+ )
returnValue(False)
else:
- responses.add(recipient.cuaddr, responsecode.OK, reqstatus=iTIPRequestStatus.SUCCESS, calendar=fbresult)
+ responses.add(
+ recipient.cuaddr,
+ responsecode.OK,
+ reqstatus=iTIPRequestStatus.SUCCESS,
+ calendar=fbresult
+ )
returnValue(True)
@inlineCallbacks
Modified: CalendarServer/trunk/twistedcaldav/scheduling/imip.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/imip.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/scheduling/imip.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -66,8 +66,15 @@
):
log.info("Could not do server-to-imip method: %s" % (method,))
for recipient in self.recipients:
- err = HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "recipient-failed")))
- self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.NO_USER_SUPPORT)
+ err = HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "recipient-failed")
+ ))
+ self.responses.add(
+ recipient.cuaddr,
+ Failure(exc_value=err),
+ reqstatus=iTIPRequestStatus.NO_USER_SUPPORT
+ )
returnValue(None)
caldata = str(self.scheduler.calendar)
@@ -86,18 +93,36 @@
except Exception, e:
# Generated failed response for this recipient
log.err("Could not do server-to-imip request : %s %s" % (self, e))
- err = HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "recipient-failed")))
- self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.SERVICE_UNAVAILABLE)
+ err = HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "recipient-failed")
+ ))
+ self.responses.add(
+ recipient.cuaddr,
+ Failure(exc_value=err),
+ reqstatus=iTIPRequestStatus.SERVICE_UNAVAILABLE
+ )
else:
- self.responses.add(recipient.cuaddr, responsecode.OK, reqstatus=iTIPRequestStatus.MESSAGE_SENT)
+ self.responses.add(
+ recipient.cuaddr,
+ responsecode.OK,
+ reqstatus=iTIPRequestStatus.MESSAGE_SENT
+ )
except Exception, e:
# Generated failed responses for each recipient
log.err("Could not do server-to-imip request : %s %s" % (self, e))
for recipient in self.recipients:
- err = HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "recipient-failed")))
- self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.SERVICE_UNAVAILABLE)
+ err = HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "recipient-failed")
+ ))
+ self.responses.add(
+ recipient.cuaddr,
+ Failure(exc_value=err),
+ reqstatus=iTIPRequestStatus.SERVICE_UNAVAILABLE
+ )
def postToGateway(self, fromAddr, toAddr, caldata, reactor=None):
if reactor is None:
Modified: CalendarServer/trunk/twistedcaldav/scheduling/implicit.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/implicit.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/scheduling/implicit.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -88,8 +88,16 @@
yield self.checkImplicitState()
# Attendees are not allowed to overwrite one type with another
- if not self.internal_request and self.state == "attendee" and (existing_type != new_type) and existing_resource:
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-attendee-change")))
+ if (
+ not self.internal_request and
+ self.state == "attendee" and
+ (existing_type != new_type) and
+ existing_resource
+ ):
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-attendee-change")
+ ))
returnValue((self.action != "none", new_type == "schedule",))
@@ -110,7 +118,10 @@
if srccal and destcal:
if src_is_implicit and dest_exists or dest_is_implicit:
log.debug("Implicit - cannot MOVE with a scheduling object resource")
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "unique-scheduling-object-resource")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "unique-scheduling-object-resource")
+ ))
else:
self.action = "none"
elif srccal and not destcal:
@@ -140,7 +151,10 @@
if srccal and destcal:
if src_is_implicit or dest_is_implicit:
log.debug("Implicit - cannot COPY with a scheduling object resource")
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "unique-scheduling-object-resource")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "unique-scheduling-object-resource")
+ ))
else:
self.action = "none"
elif srccal and not destcal:
@@ -308,7 +322,10 @@
self.originatorPrincipal = (yield self.resource.ownerPrincipal(self.request))
if not isinstance(self.originatorPrincipal, DirectoryCalendarPrincipalResource):
log.error("Originator '%s' is not enabled for calendaring" % (self.originatorPrincipal,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "invalid-originator")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "invalid-originator")
+ ))
# Pick the first mailto cu address or the first other type
for item in self.originatorPrincipal.calendarUserAddresses():
@@ -324,7 +341,10 @@
except ValueError:
# We have different ORGANIZERs in the same iCalendar object - this is an error
log.error("Only one ORGANIZER is allowed in an iCalendar object:\n%s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "single-organizer")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "single-organizer")
+ ))
# Get the ATTENDEEs
self.attendeesByInstance = self.calendar.getAttendeesByInstance(True, onlyScheduleAgentServer=True)
@@ -354,7 +374,10 @@
foundElsewhere = (yield calendar_home.hasCalendarResourceUIDSomewhereElse(self.uid, check_resource, type))
if foundElsewhere:
log.debug("Implicit - found component with same UID in a different collection: %s" % (check_uri,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "unique-scheduling-object-resource")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "unique-scheduling-object-resource")
+ ))
@inlineCallbacks
def isOrganizerScheduling(self):
@@ -526,7 +549,10 @@
newOrganizer = self.calendar.getOrganizer()
if oldOrganizer != newOrganizer:
log.error("Cannot change ORGANIZER: UID:%s" % (self.uid,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-organizer-change")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-organizer-change")
+ ))
else:
# Special case of SCHEDULE-FORCE-SEND added to attendees and no other change
reinvites = set()
@@ -755,7 +781,10 @@
newOrganizer = self.calendar.getOrganizer()
if oldOrganizer != newOrganizer:
log.error("Cannot change ORGANIZER: UID:%s" % (self.uid,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-attendee-change")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-attendee-change")
+ ))
else:
self.oldcalendar = None
@@ -766,7 +795,10 @@
# If Organizer copy exists we cannot allow SCHEDULE-AGENT=CLIENT or NONE
if not doScheduling:
log.error("Attendee '%s' is not allowed to change SCHEDULE-AGENT on organizer: UID:%s" % (self.attendeePrincipal, self.uid,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-attendee-change")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-attendee-change")
+ ))
# Determine whether the current change is allowed
changeAllowed, doITipReply, changedRids, newCalendar = self.isAttendeeChangeInsignificant()
@@ -780,7 +812,10 @@
returnValue(None)
else:
log.error("Attendee '%s' is not allowed to make an unauthorized change to an organized event: UID:%s" % (self.attendeePrincipal, self.uid,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-attendee-change")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-attendee-change")
+ ))
if not doITipReply:
log.debug("Implicit - attendee '%s' is updating UID: '%s' but change is not significant" % (self.attendee, self.uid))
@@ -801,7 +836,10 @@
oldScheduling = self.oldcalendar.getOrganizerScheduleAgent()
if not oldScheduling:
log.error("Attendee '%s' is not allowed to set SCHEDULE-AGENT=SERVER on organizer: UID:%s" % (self.attendeePrincipal, self.uid,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-attendee-change")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-attendee-change")
+ ))
log.debug("Attendee '%s' is not allowed to update UID: '%s' - missing organizer copy - removing entire event" % (self.attendee, self.uid,))
self.return_status = ImplicitScheduler.STATUS_ORPHANED_EVENT
Modified: CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -90,7 +90,10 @@
assert False, "Incorrect calendar user address class"
if not server:
# Cannot do server-to-server for this recipient.
- err = HTTPError(ErrorResponse(responsecode.NOT_FOUND, (caldav_namespace, "recipient-allowed")))
+ err = HTTPError(ErrorResponse(
+ responsecode.NOT_FOUND,
+ (caldav_namespace, "recipient-allowed")
+ ))
self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.NO_USER_SUPPORT)
# Process next recipient
@@ -98,7 +101,10 @@
if not server.allow_to:
# Cannot do server-to-server outgoing requests for this server.
- err = HTTPError(ErrorResponse(responsecode.NOT_FOUND, (caldav_namespace, "recipient-allowed")))
+ err = HTTPError(ErrorResponse(
+ responsecode.NOT_FOUND,
+ (caldav_namespace, "recipient-allowed")
+ ))
self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.SERVICE_UNAVAILABLE)
# Process next recipient
@@ -169,7 +175,10 @@
# Generated failed responses for each recipient
log.err("Could not do server-to-server request : %s %s" % (self, e))
for recipient in self.recipients:
- err = HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "recipient-failed")))
+ err = HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "recipient-failed")
+ ))
self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.SERVICE_UNAVAILABLE)
def logRequest(self, level, message, request, **kwargs):
Modified: CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -181,7 +181,10 @@
if not originator:
log.err("%s request must have Originator" % (self.method,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-specified")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "originator-specified")
+ ))
else:
self.originator = originator
@@ -197,7 +200,10 @@
if not attendees:
log.err("%s request must have at least one Recipient" % (self.method,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "recipient-specified")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "recipient-specified")
+ ))
else:
self.recipients = list(attendees)
@@ -213,7 +219,10 @@
originator = self.request.headers.getRawHeaders("originator")
if originator is None or (len(originator) != 1):
log.err("%s request must have Originator header" % (self.method,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-specified")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "originator-specified")
+ ))
else:
self.originator = originator[0]
@@ -222,7 +231,10 @@
rawRecipients = self.request.headers.getRawHeaders("recipient")
if rawRecipients is None or (len(rawRecipients) == 0):
log.err("%s request must have at least one Recipient header" % (self.method,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "recipient-specified")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "recipient-specified")
+ ))
# Recipient header may be comma separated list
self.recipients = []
@@ -238,7 +250,10 @@
contentType = self.request.headers.getHeader("content-type")
if contentType is not None and (contentType.mediaType, contentType.mediaSubtype) != ("text", "calendar"):
log.err("MIME type %s not allowed in calendar collection" % (contentType,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "supported-calendar-data")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "supported-calendar-data")
+ ))
# Parse the calendar object from the HTTP request stream
try:
@@ -247,7 +262,11 @@
except:
# FIXME: Bare except
log.err("Error while handling %s: %s" % (self.method, Failure(),))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description="Can't parse calendar data"))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-calendar-data"),
+ description="Can't parse calendar data"
+ ))
def checkAuthorization(self):
raise NotImplementedError
@@ -273,22 +292,37 @@
self.calendar.validCalendarForCalDAV()
except ValueError, e:
log.err("%s request calendar component is not valid:%s %s" % (self.method, e, self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description="Calendar component is not valid"))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-calendar-data"),
+ description="Calendar component is not valid"
+ ))
# Must have a METHOD
if not self.calendar.isValidMethod():
log.err("%s request must have valid METHOD property in calendar component: %s" % (self.method, self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description="Must have valid METHOD property"))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-calendar-data"),
+ description="Must have valid METHOD property"
+ ))
# Verify iTIP behavior
if not self.calendar.isValidITIP():
log.err("%s request must have a calendar component that satisfies iTIP requirements: %s" % (self.method, self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description="Must have a calendar component that satisfies iTIP requirements"))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-calendar-data"),
+ description="Must have a calendar component that satisfies iTIP requirements"
+ ))
# X-CALENDARSERVER-ACCESS is not allowed in Outbox POSTs
if self.calendar.hasProperty(Component.ACCESS_PROPERTY):
log.err("X-CALENDARSERVER-ACCESS not allowed in a calendar component %s request: %s" % (self.method, self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (calendarserver_namespace, "no-access-restrictions")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (calendarserver_namespace, "no-access-restrictions")
+ ))
# Determine iTIP method mode
if self.calendar.propertyValue("METHOD") in ("PUBLISH", "REQUEST", "ADD", "CANCEL", "DECLINECOUNTER"):
@@ -303,13 +337,20 @@
# Must have only one
if len(attendees) != 1:
log.err("Wrong number of ATTENDEEs in calendar data: %s" % (self.calendardata,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "attendee-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "attendee-allowed")
+ ))
self.attendee = attendees[0]
else:
msg = "Unknown iTIP METHOD: %s" % (self.calendar.propertyValue("METHOD"),)
log.err(msg)
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description=msg))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-calendar-data"),
+ description=msg
+ ))
def checkForFreeBusy(self):
if not hasattr(self, "isfreebusy"):
@@ -318,17 +359,28 @@
vfreebusies = [v for v in self.calendar.subcomponents() if v.name() == "VFREEBUSY"]
if len(vfreebusies) != 1:
log.err("iTIP data is not valid for a VFREEBUSY request: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description="iTIP data is not valid for a VFREEBUSY request"))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-calendar-data"), description="iTIP data is not valid for a VFREEBUSY request"
+ ))
dtstart = vfreebusies[0].getStartDateUTC()
dtend = vfreebusies[0].getEndDateUTC()
if dtstart is None or dtend is None:
log.err("VFREEBUSY start/end not valid: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description="VFREEBUSY start/end not valid"))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-calendar-data"),
+ description="VFREEBUSY start/end not valid"
+ ))
# Some clients send floating instead of UTC - coerce to UTC
if dtstart.tzinfo is None or dtend.tzinfo is None:
log.err("VFREEBUSY start or end not UTC: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description="VFREEBUSY start or end not UTC"))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-calendar-data"),
+ description="VFREEBUSY start or end not UTC"
+ ))
self.timeRange = caldavxml.TimeRange(start=iCalendarString(dtstart), end=iCalendarString(dtend))
self.timeRange.start = dtstart
@@ -398,7 +450,10 @@
# Check for freebusy limit
if freebusy and config.Scheduling.Options.LimitFreeBusyAttendees and ctr >= config.Scheduling.Options.LimitFreeBusyAttendees:
- err = HTTPError(ErrorResponse(responsecode.NOT_FOUND, (caldav_namespace, "recipient-limit")))
+ err = HTTPError(ErrorResponse(
+ responsecode.NOT_FOUND,
+ (caldav_namespace, "recipient-limit")
+ ))
responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.SERVICE_UNAVAILABLE)
continue
@@ -418,7 +473,10 @@
imip_recipients.append(recipient)
else:
- err = HTTPError(ErrorResponse(responsecode.NOT_FOUND, (caldav_namespace, "recipient-exists")))
+ err = HTTPError(ErrorResponse(
+ responsecode.NOT_FOUND,
+ (caldav_namespace, "recipient-exists")
+ ))
responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.INVALID_CALENDAR_USER)
# Now process local recipients
@@ -487,7 +545,10 @@
# Must have an authenticated user
if not self.internal_request and self.resource.currentPrincipal(self.request) == davxml.Principal(davxml.Unauthenticated()):
log.err("Unauthenticated originators not allowed: %s" % (self.originator,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "originator-allowed")
+ ))
def checkOriginator(self):
"""
@@ -499,13 +560,19 @@
if originatorPrincipal is None:
# Local requests MUST have a principal.
log.err("Could not find principal for originator: %s" % (self.originator,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "originator-allowed")
+ ))
else:
# Must have a valid Inbox.
inboxURL = originatorPrincipal.scheduleInboxURL()
if inboxURL is None:
log.err("Could not find inbox for originator: %s" % (self.originator,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "originator-allowed")
+ ))
self.originator = LocalCalendarUser(self.originator, originatorPrincipal)
@@ -559,34 +626,52 @@
if outboxURL:
if not organizerPrincipal.enabledAsOrganizer():
log.err("ORGANIZER not allowed to be an Organizer: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "organizer-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "organizer-allowed")
+ ))
self.organizer = LocalCalendarUser(organizer, organizerPrincipal)
else:
log.err("No outbox for ORGANIZER in calendar data: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "organizer-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "organizer-allowed")
+ ))
else:
localUser = (yield addressmapping.mapper.isCalendarUserInMyDomain(organizer))
if localUser:
log.err("No principal for ORGANIZER in calendar data: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "organizer-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "organizer-allowed")
+ ))
else:
self.organizer = RemoteCalendarUser(organizer)
else:
log.err("ORGANIZER missing in calendar data: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "organizer-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "organizer-allowed")
+ ))
def checkOrganizerAsOriginator(self):
# Make sure that the ORGANIZER is local
if not isinstance(self.organizer, LocalCalendarUser):
log.err("ORGANIZER is not local to server in calendar data: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "organizer-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "organizer-allowed")
+ ))
# Make sure that the ORGANIZER's Outbox is the request URI
if self.doingPOST and self.organizer.principal.scheduleOutboxURL() != self.request.uri:
log.err("Wrong outbox for ORGANIZER in calendar data: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "organizer-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "organizer-allowed")
+ ))
def checkAttendeeAsOriginator(self):
"""
@@ -599,10 +684,16 @@
if attendeePrincipal:
if self.doingPOST and attendeePrincipal.scheduleOutboxURL() != self.request.uri:
log.err("ATTENDEE in calendar data does not match owner of Outbox: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "attendee-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "attendee-allowed")
+ ))
else:
log.err("Unknown ATTENDEE in calendar data: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "attendee-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "attendee-allowed")
+ ))
def securityChecks(self):
"""
@@ -700,7 +791,10 @@
# Must have an unauthenticated user
if self.resource.currentPrincipal(self.request) != davxml.Principal(davxml.Unauthenticated()):
log.err("Authenticated originators not allowed: %s" % (self.originator,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "originator-allowed")
+ ))
@inlineCallbacks
def checkOriginator(self):
@@ -714,7 +808,10 @@
if originatorPrincipal or localUser:
if originatorPrincipal.locallyHosted():
log.err("Cannot use originator that is on this server: %s" % (self.originator,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "originator-allowed")
+ ))
else:
self.originator = PartitionedCalendarUser(self.originator, originatorPrincipal)
#self._validPartitionServer()
@@ -732,7 +829,10 @@
server = servermgr.mapDomain(self.originator.domain)
if not server or not server.allow_from:
log.err("Originator not on recognized server: %s" % (self.originator,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "originator-allowed")
+ ))
else:
# Get the request IP and map to hostname.
clientip = self.request.remoteAddr.host
@@ -768,7 +868,10 @@
if not matched:
log.err("Originator not on allowed server: %s" % (self.originator,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "originator-allowed")
+ ))
def _validPartitionServer(self, principal):
"""
@@ -800,7 +903,10 @@
if not matched:
log.err("Originator not on allowed server: %s" % (self.originator,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "originator-allowed")
+ ))
@inlineCallbacks
def checkOrganizerAsOriginator(self):
@@ -815,7 +921,10 @@
if organizerPrincipal:
if organizerPrincipal.locallyHosted():
log.err("Invalid ORGANIZER in calendar data: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "organizer-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "organizer-allowed")
+ ))
else:
# Check that the origin server is the correct partition
self.organizer = PartitionedCalendarUser(organizer, organizerPrincipal)
@@ -824,12 +933,18 @@
localUser = (yield addressmapping.mapper.isCalendarUserInMyDomain(organizer))
if localUser:
log.err("Unsupported ORGANIZER in calendar data: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "organizer-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "organizer-allowed")
+ ))
else:
self.organizer = RemoteCalendarUser(organizer)
else:
log.err("ORGANIZER missing in calendar data: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "organizer-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "organizer-allowed")
+ ))
@inlineCallbacks
def checkAttendeeAsOriginator(self):
@@ -843,14 +958,20 @@
if attendeePrincipal:
if attendeePrincipal.locallyHosted():
log.err("Invalid ATTENDEE in calendar data: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "attendee-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "attendee-allowed")
+ ))
else:
self._validPartitionServer(attendeePrincipal)
else:
localUser = (yield addressmapping.mapper.isCalendarUserInMyDomain(self.attendee))
if localUser:
log.err("Unknown ATTENDEE in calendar data: %s" % (self.calendar,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "attendee-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "attendee-allowed")
+ ))
# TODO: in this case we should check that the ORGANIZER is the sole recipient.
@@ -871,7 +992,10 @@
else:
msg = "Unknown iTIP METHOD for security checks: %s" % (self.calendar.propertyValue("METHOD"),)
log.err(msg)
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description=msg))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-calendar-data"), description=msg
+ ))
class DirectScheduler(Scheduler):
@@ -916,7 +1040,10 @@
localUser = (yield addressmapping.mapper.isCalendarUserInMyDomain(self.originator))
if originatorPrincipal or localUser:
log.err("Cannot use originator that is on this server: %s" % (self.originator,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "originator-allowed")
+ ))
else:
self.originator = RemoteCalendarUser(self.originator)
@@ -940,7 +1067,10 @@
else:
log.err("Only %s is allowed to submit internal scheduling requests, not %s" % (allowed, host))
# TODO: verify this is the right response:
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "originator-allowed")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "originator-allowed")
+ ))
class ScheduleResponseResponse (Response):
Modified: CalendarServer/trunk/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/sharing.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/sharing.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -733,7 +733,10 @@
doc = davxml.WebDAVDocument.fromString(data)
except ValueError, e:
self.log_error("Error parsing doc (%s) Doc:\n %s" % (str(e), data,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (customxml.calendarserver_namespace, "valid-request")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (customxml.calendarserver_namespace, "valid-request")
+ ))
root = doc.root_element
xmlDocHanders = {
@@ -743,7 +746,10 @@
return xmlDocHanders[type(root)](root).addErrback(_handleErrorResponse)
else:
self.log_error("Unsupported XML (%s)" % (root,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (customxml.calendarserver_namespace, "valid-request")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (customxml.calendarserver_namespace, "valid-request")
+ ))
return allDataFromStream(request.stream).addCallback(_getData)
@@ -753,7 +759,10 @@
if mimetype.mediaType in ("application", "text",) and mimetype.mediaSubtype == "xml":
encoding = mimetype.params["charset"] if "charset" in mimetype.params else "utf8"
return succeed(encoding)
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (customxml.calendarserver_namespace, "valid-request")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (customxml.calendarserver_namespace, "valid-request")
+ ))
def xmlPOSTAuth(self, request):
d = self.authorize(request, (davxml.Read(), davxml.Write()))
@@ -1187,7 +1196,11 @@
return xmlDocHanders[type(root)](root).addErrback(_handleErrorResponse)
else:
self.log_error("Unsupported XML (%s)" % (root,))
- raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (customxml.calendarserver_namespace, "valid-request")))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (customxml.calendarserver_namespace,
+ "valid-request")
+ ))
return allDataFromStream(request.stream).addCallback(_getData)
Modified: CalendarServer/trunk/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/storebridge.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -622,11 +622,16 @@
default = (yield self.isDefaultCalendar(request))
if default:
log.err("Cannot DELETE default calendar: %s" % (self,))
- raise HTTPError(ErrorResponse(FORBIDDEN,
- (caldav_namespace,
- "default-calendar-delete-allowed",)))
+ raise HTTPError(ErrorResponse(
+ FORBIDDEN,
+ (caldav_namespace, "default-calendar-delete-allowed",)
+ ))
- response = (yield super(CalendarCollectionResource, self).storeRemove(request, implicitly, where))
+ response = (
+ yield super(CalendarCollectionResource, self).storeRemove(
+ request, implicitly, where
+ )
+ )
if response == NO_CONTENT:
# Do some clean up
Modified: CalendarServer/trunk/twistedcaldav/timezoneservice.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/timezoneservice.py 2011-01-25 21:49:41 UTC (rev 6804)
+++ CalendarServer/trunk/twistedcaldav/timezoneservice.py 2011-01-25 21:50:03 UTC (rev 6805)
@@ -144,7 +144,10 @@
method = request.args.get("method", ("",))
if len(method) != 1:
- raise HTTPError(ErrorResponse(responsecode.BAD_REQUEST, (calendarserver_namespace, "valid-method")))
+ raise HTTPError(ErrorResponse(
+ responsecode.BAD_REQUEST,
+ (calendarserver_namespace, "valid-method")
+ ))
method = method[0]
action = {
@@ -154,7 +157,10 @@
}.get(method, None)
if action is None:
- raise HTTPError(ErrorResponse(responsecode.BAD_REQUEST, (calendarserver_namespace, "supported-method")))
+ raise HTTPError(ErrorResponse(
+ responsecode.BAD_REQUEST,
+ (calendarserver_namespace, "supported-method")
+ ))
return action(request)
@@ -179,13 +185,19 @@
tzid = request.args.get("tzid", ())
if len(tzid) != 1:
- raise HTTPError(ErrorResponse(responsecode.BAD_REQUEST, (calendarserver_namespace, "valid-timezone")))
+ raise HTTPError(ErrorResponse(
+ responsecode.BAD_REQUEST,
+ (calendarserver_namespace, "valid-timezone")
+ ))
tzid = tzid[0]
try:
tzdata = readTZ(tzid)
except TimezoneException:
- raise HTTPError(ErrorResponse(responsecode.NOT_FOUND, (calendarserver_namespace, "timezone-available")))
+ raise HTTPError(ErrorResponse(
+ responsecode.NOT_FOUND,
+ (calendarserver_namespace, "timezone-available")
+ ))
response = Response()
response.stream = MemoryStream(tzdata)
@@ -199,12 +211,18 @@
tzid = request.args.get("tzid", ())
if len(tzid) != 1:
- raise HTTPError(ErrorResponse(responsecode.BAD_REQUEST, (calendarserver_namespace, "valid-timezone")))
+ raise HTTPError(ErrorResponse(
+ responsecode.BAD_REQUEST,
+ (calendarserver_namespace, "valid-timezone")
+ ))
tzid = tzid[0]
try:
tzdata = readTZ(tzid)
except TimezoneException:
- raise HTTPError(ErrorResponse(responsecode.NOT_FOUND, (calendarserver_namespace, "timezone-available")))
+ raise HTTPError(ErrorResponse(
+ responsecode.NOT_FOUND,
+ (calendarserver_namespace, "timezone-available")
+ ))
try:
start = request.args.get("start", ())
@@ -212,7 +230,10 @@
raise ValueError()
start = parse_date_or_datetime(start[0])
except ValueError:
- raise HTTPError(ErrorResponse(responsecode.BAD_REQUEST, (calendarserver_namespace, "valid-start-date")))
+ raise HTTPError(ErrorResponse(
+ responsecode.BAD_REQUEST,
+ (calendarserver_namespace, "valid-start-date")
+ ))
try:
end = request.args.get("end", ())
@@ -222,7 +243,10 @@
if end <= start:
raise ValueError()
except ValueError:
- raise HTTPError(ErrorResponse(responsecode.BAD_REQUEST, (calendarserver_namespace, "valid-end-date")))
+ raise HTTPError(ErrorResponse(
+ responsecode.BAD_REQUEST,
+ (calendarserver_namespace, "valid-end-date")
+ ))
# Now do the expansion (but use a cache to avoid re-calculating TZs)
observances = self.cache.get((tzid, start, end), None)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110125/69d97a0a/attachment-0001.html>
More information about the calendarserver-changes
mailing list