def validate(self, value): """ """ if value is None: msg = _("Please provide a valid URL.") raise interfaces.InvalidURI(msg) urls = [v.strip() for v in value.split()] verify = validation.validatorFor("isURL") for url in urls: # Google's (and perhaps other) ICS URLs don't validate, so we only # validate the first part... surl = '/'.join(url.split('/')[:3]) if verify(str(surl)) != True: msg = _("The specified resource, '%s' is not a valid URL." % url) raise interfaces.InvalidURI(msg)
def add_and_refresh(self, action): data, errors = self.extractData() if errors: self.status = _("Please correct the following errors before saving the form") return if data.has_key("calendar_urls"): urls = [v for v in data["calendar_urls"].split()] utils.fetch_calendars(self.context, self.request, urls) else: urls = [] annotations = IAnnotations(self.context) annotations["slc.calendarfetcher-urls"] = urls addStatusMessage(self.request, "URLs Saved", type="info") self.request.response.redirect(self.context.REQUEST.get("URL"))