X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/2a3bb0d2d5fff8c3c373af2f493d2f9da8c8a35c..62a09d63946a6942250f5af2f1159b37a0bbc9fa:/philo/contrib/winer/models.py diff --git a/philo/contrib/winer/models.py b/philo/contrib/winer/models.py index 5e85cc3..4acf5d1 100644 --- a/philo/contrib/winer/models.py +++ b/philo/contrib/winer/models.py @@ -87,19 +87,15 @@ class FeedView(MultiView): .. seealso:: :meth:`get_feed_type` """ - urlpatterns = patterns('') + feed_patterns = () if self.feeds_enabled: suffixes = [(self.feed_suffix, None)] + [(slug, slug) for slug in registry] for suffix, feed_type in suffixes: feed_view = http_not_acceptable(self.feed_view(get_items_attr, reverse_name, feed_type)) feed_pattern = r'%s%s%s$' % (base, "/" if base and base[-1] != "^" else "", suffix) - urlpatterns += patterns('', - url(feed_pattern, feed_view, name="%s_%s" % (reverse_name, suffix)), - ) - urlpatterns += patterns('', - url(r"%s$" % base, self.page_view(get_items_attr, page_attr), name=reverse_name) - ) - return urlpatterns + feed_patterns += (url(feed_pattern, feed_view, name="%s_%s" % (reverse_name, suffix)),) + feed_patterns += (url(r"%s$" % base, self.page_view(get_items_attr, page_attr), name=reverse_name),) + return patterns('', *feed_patterns) def get_object(self, request, **kwargs): """By default, returns the object stored in the attribute named by :attr:`object_attr`. This can be overridden for subclasses that publish different data for different URL parameters. It is part of the :class:`django.contrib.syndication.views.Feed` API.""" @@ -109,7 +105,7 @@ class FeedView(MultiView): """ Returns a view function that renders a list of items as a feed. - :param get_items_attr: A callable or the name of a callable on the :class:`FeedView` that will return a (items, extra_context) tuple when called with view arguments. + :param get_items_attr: A callable or the name of a callable on the :class:`FeedView` that will return a (items, extra_context) tuple when called with the object for the feed and view arguments. :param reverse_name: The name which can be used reverse the page for this feed using the :class:`FeedView` as the urlconf. :param feed_type: The slug used to render the feed class which will be used by the returned view function. @@ -121,7 +117,7 @@ class FeedView(MultiView): def inner(request, extra_context=None, *args, **kwargs): obj = self.get_object(request, *args, **kwargs) feed = self.get_feed(obj, request, reverse_name, feed_type, *args, **kwargs) - items, xxx = get_items(request, extra_context=extra_context, *args, **kwargs) + items, xxx = get_items(obj, request, extra_context=extra_context, *args, **kwargs) self.populate_feed(feed, items, request) response = HttpResponse(mimetype=feed.mime_type) @@ -139,16 +135,17 @@ class FeedView(MultiView): """ get_items = get_items_attr if callable(get_items_attr) else getattr(self, get_items_attr) - page = page_attr if isinstance(page_attr, Page) else getattr(self, page_attr) def inner(request, extra_context=None, *args, **kwargs): - items, extra_context = get_items(request, extra_context=extra_context, *args, **kwargs) + obj = self.get_object(request, *args, **kwargs) + items, extra_context = get_items(obj, request, extra_context=extra_context, *args, **kwargs) items, item_context = self.process_page_items(request, items) context = self.get_context() context.update(extra_context or {}) context.update(item_context or {}) + page = page_attr if isinstance(page_attr, Page) else getattr(self, page_attr) return page.render_to_response(request, extra_context=context) return inner