Python django.contrib.syndication.views.Feed() Examples
The following are 3
code examples of django.contrib.syndication.views.Feed().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.contrib.syndication.views
, or try the search function
.
Example #1
Source File: views.py From django-ical with MIT License | 6 votes |
def _get_dynamic_attr(self, attname, obj, default=None): """ Copied from django.contrib.syndication.views.Feed (v1.7.1) """ try: attr = getattr(self, attname) except AttributeError: return default if callable(attr): num_args = len(signature(attr).parameters) if num_args == 0: return attr() if num_args == 1: return attr(obj) raise TypeError( "Number of arguments to _get_dynamic_attr needs to be 0 or 1" ) return attr # NOTE: Not used by icalendar but required # by the Django syndication framework.
Example #2
Source File: views.py From django-ical with MIT License | 5 votes |
def __call__(self, request, *args, **kwargs): """ Copied from django.contrib.syndication.views.Feed Supports file_name as a dynamic attr. """ try: obj = self.get_object(request, *args, **kwargs) except ObjectDoesNotExist: raise Http404("Feed object does not exist.") feedgen = self.get_feed(obj, request) response = HttpResponse( content_type="text/calendar, text/x-vcalendar, application/hbs-vcs" ) if hasattr(self, "item_pubdate") or hasattr(self, "item_updateddate"): # if item_pubdate or item_updateddate is defined for the feed, set # header so as ConditionalGetMiddleware is able to send 304 NOT MODIFIED response["Last-Modified"] = http_date( timegm(feedgen.latest_post_date().utctimetuple()) ) feedgen.write(response, "utf-8") filename = self._get_dynamic_attr("file_name", obj) if filename: response["Content-Disposition"] = 'attachment; filename="%s"' % filename return response
Example #3
Source File: feeds.py From tramcar with MIT License | 5 votes |
def title(self, obj): return '%s - %s Jobs Feed' % (obj.site.name, obj.name)