def render(self): sdata = magicstring(ical_string(self.ical_event())) resp = magicstring(sdata) lresp = len(resp) self.request.response.setHeader('Content-Type','text/calendar') self.request.response.addHeader( "Content-Disposition","filename=%s.ics" % ( self.context.getId())) self.request.response.setHeader('Content-Length', len(resp)) self.request.response.write(resp)
def to_string(value): if isinstance(value, unicode): try: value = str(value) except: value = magicstring(value) return value
def to_unicode(value): if not isinstance(value, unicode): try: value = unicode(value) except: value = magicstring(value).decode('utf-8') return value
def render(self): events = [] for i in self.items: event = i.getObject() icalv = event.restrictedTraverse('@@ical') events.append(icalv.ical_event()) resp = magicstring(ical_string(events)) self.request.response.setHeader('Content-Type','text/calendar') self.request.response.addHeader( "Content-Disposition","filename=%s.ics" % ( self.context.getId())) self.request.response.setHeader('Content-Length', len(resp)) self.request.response.write(resp)
def __call__(self, context, key=None): if not key: key=self.key registry = component.queryUtility(IRegistry) if registry is None: return [] categories = registry[key] if not categories: categories = [] categories = [utils.magicstring(c.strip()).decode('utf-8') for c in categories] terms = [SimpleTerm(baseNormalize(category), baseNormalize(category), category) for category in uniquify(categories)] return SimpleVocabulary(terms)