def loadCalendarFromRequest(self, request): # Must be content-type text/calendar contentType = request.headers.getHeader("content-type") format = self.determineType(contentType) if format is None: self.log.error("MIME type %s not allowed in calendar collection" % (contentType, )) raise HTTPError( ErrorResponse( responsecode.FORBIDDEN, (caldav_namespace, "supported-calendar-data"), "Data is not calendar data", )) # Parse the calendar object from the HTTP request stream try: calendar = (yield Component.fromIStream(request.stream, format=format)) except: # FIXME: Bare except self.log.error("Error while handling POST: %s" % (Failure(), )) raise HTTPError( ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description="Can't parse calendar data")) returnValue(( calendar, format, ))
def loadCalendarFromRequest(self, request): # Must be content-type text/calendar contentType = request.headers.getHeader("content-type") if contentType is not None and (contentType.mediaType, contentType.mediaSubtype) != ("text", "calendar"): self.log.error( "MIME type {ct} not allowed in iSchedule POST request", ct=contentType, ) raise HTTPError(ErrorResponse( responsecode.FORBIDDEN, (ischedule_namespace, "invalid-calendar-data-type"), "Data is not calendar data", )) # Parse the calendar object from the HTTP request stream try: calendar = (yield Component.fromIStream(request.stream)) except: # FIXME: Bare except self.log.error( "Error while handling iSchedule POST: {f}", f=Failure(), ) raise HTTPError(ErrorResponse( responsecode.FORBIDDEN, (ischedule_namespace, "invalid-calendar-data"), description="Can't parse calendar data" )) returnValue(calendar)
def loadCalendarFromRequest(self, request): # Must be content-type text/calendar contentType = request.headers.getHeader("content-type") format = self.determineType(contentType) if format is None: self.log.error("MIME type %s not allowed in calendar collection" % (contentType,)) raise HTTPError(ErrorResponse( responsecode.FORBIDDEN, (caldav_namespace, "supported-calendar-data"), "Data is not calendar data", )) # Parse the calendar object from the HTTP request stream try: calendar = (yield Component.fromIStream(request.stream, format=format)) except: # FIXME: Bare except self.log.error("Error while handling POST: %s" % (Failure(),)) raise HTTPError(ErrorResponse( responsecode.FORBIDDEN, (caldav_namespace, "valid-calendar-data"), description="Can't parse calendar data" )) returnValue((calendar, format,))
def do_test(response): response = IResponse(response) if response.code != responsecode.OK: self.fail("REPORT failed: %s" % (response.code,)) return Component.fromIStream(response.stream).addCallback(got_calendar)
def loadCalendarFromRequest(self, request): # Must be content-type text/calendar contentType = request.headers.getHeader("content-type") if contentType is not None and (contentType.mediaType, contentType. mediaSubtype) != ("text", "calendar"): self.log.error( "MIME type {ct} not allowed in iSchedule POST request", ct=contentType, ) raise HTTPError( ErrorResponse( responsecode.FORBIDDEN, (ischedule_namespace, "invalid-calendar-data-type"), "Data is not calendar data", )) # Parse the calendar object from the HTTP request stream try: calendar = (yield Component.fromIStream(request.stream)) except: # FIXME: Bare except self.log.error( "Error while handling iSchedule POST: {f}", f=Failure(), ) raise HTTPError( ErrorResponse(responsecode.FORBIDDEN, (ischedule_namespace, "invalid-calendar-data"), description="Can't parse calendar data")) returnValue(calendar)
def free_busy_query(self, calendar_uri, query, got_calendar): request = SimpleRequest(self.site, "MKCALENDAR", calendar_uri) response = yield self.send(request) response = IResponse(response) if response.code != responsecode.CREATED: self.fail("MKCALENDAR failed: %s" % (response.code, )) yield addEventsDir(self, FilePath(self.holidays_dir), calendar_uri) request = SimpleRequest(self.site, "REPORT", calendar_uri) request.stream = MemoryStream(query.toxml()) response = yield self.send(request) response = IResponse(response) if response.code != responsecode.OK: self.fail("REPORT failed: %s" % (response.code, )) result = yield Component.fromIStream( response.stream).addCallback(got_calendar) returnValue(result)
def free_busy_query(self, calendar_uri, query, got_calendar): request = SimpleRequest(self.site, "MKCALENDAR", calendar_uri) response = yield self.send(request) response = IResponse(response) if response.code != responsecode.CREATED: self.fail("MKCALENDAR failed: %s" % (response.code,)) yield addEventsDir(self, FilePath(self.holidays_dir), calendar_uri) request = SimpleRequest(self.site, "REPORT", calendar_uri) request.stream = MemoryStream(query.toxml()) response = yield self.send(request) response = IResponse(response) if response.code != responsecode.OK: self.fail("REPORT failed: %s" % (response.code,)) result = yield Component.fromIStream(response.stream).addCallback( got_calendar ) returnValue(result)
def loadCalendarFromRequest(self): # Must be content-type text/calendar 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(self.errorResponse( responsecode.FORBIDDEN, self.errorElements["invalid-calendar-data-type"], "Data is not calendar data", )) # Parse the calendar object from the HTTP request stream try: self.calendar = (yield Component.fromIStream(self.request.stream)) self.preProcessCalendarData() except: # FIXME: Bare except log.err("Error while handling %s: %s" % (self.method, Failure(),)) raise HTTPError(self.errorResponse( responsecode.FORBIDDEN, self.errorElements["invalid-calendar-data"], description="Can't parse calendar data" ))