X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/359b38924a79d43588a6a7097a154cb3d2fde62d..2b607d5a5e948a3399f110bd04583d2213db24ce:/contrib/julian/feedgenerator.py diff --git a/contrib/julian/feedgenerator.py b/contrib/julian/feedgenerator.py index 274f617..819a273 100644 --- a/contrib/julian/feedgenerator.py +++ b/contrib/julian/feedgenerator.py @@ -1,3 +1,4 @@ +from django.http import HttpResponse from django.utils.feedgenerator import SyndicationFeed import vobject @@ -40,13 +41,6 @@ ITEM_ICAL_MAP = { class ICalendarFeed(SyndicationFeed): - #def __init__(self, title, link, description, language=None, author_email=None, - # author_name=None, author_link=None, subtitle=None, categories=None, - # feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, **kwargs): - # super(ICalendarFeed, self).__init__(title, link, description, language, - # author_email, author_name, author_link, subtitle, categories, - # feed_url, feed_copyright, feed_guid, ttl, **kwargs) - # mime_type = 'text/calendar' def add_item(self, *args, **kwargs): @@ -74,4 +68,10 @@ class ICalendarFeed(SyndicationFeed): if key in ITEM_ICAL_MAP and val: event.add(ITEM_ICAL_MAP[key]).value = val - cal.serialize(outfile) \ No newline at end of file + cal.serialize(outfile) + + # Some special handling for HttpResponses. See link above. + if isinstance(outfile, HttpResponse): + filename = self.feed.get('filename', 'filename.ics') + outfile['Filename'] = filename + outfile['Content-Disposition'] = 'attachment; filename=%s' % filename \ No newline at end of file