#329 closed defect (fixed)
RSS framework needs an easier interface
Reported by: | Jacob | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | contrib.syndication | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
GarthK came up with a cool simpler interface to rss.FeedConfiguration: http://django.pastebin.com/337395
We should use it, or something close to it.
Attachments (2)
Change History (15)
by , 19 years ago
Attachment: | SimplerFeedConfiguration.txt added |
---|
comment:1 by , 19 years ago
comment:2 by , 19 years ago
Please do -- what you've got so far rocks. When you've got something you're comfortable, modify this ticket to include [patch] in the title so we'll know it's ready for review.
comment:3 by , 19 years ago
Component: | Core framework → RSS framework |
---|
comment:4 by , 19 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 19 years ago
milestone: | → Version 1.0 |
---|
comment:6 by , 19 years ago
This proposal is much more flexible but requires more code. How about allowing functions *or* attributes, so that these two would be equivalent:
class (SimplerFeedConfiguration): def description(self, feed_victim): """Return the feed descrition.""" return "Description" class (SimplerFeedConfiguration): description = "Description"
Also, whatever solution we come up with shouldn't be a wrapper of the existing FeedConfiguration
. Let's wrap feedgenerator
directly.
comment:7 by , 19 years ago
Type: | defect → enhancement |
---|
The new_rss.diff is my work on making the rss feed config work by extending a feed configuration class. It works without clobbering the existing system. I decided to keep the existing feed generator functionality so that the developer can decide which generator to use.
I also included the register_feed_modules to automagically registers any FeedConfiguration sub-classes within a list of modules. This will allow developers to put the FeedConfiguration classes anywhere. For instance if a prepackaged app has feed functionality, the developer that has added that app to his project wouldn't have to add the feed configuration to his main_rss.py module. He would simply have to add the name of the module containing the FeedConfiguration class to the list used in the call to register_feed_modules.
A good example of this could be with the comments app. It could have a feed config for the newest comments on the site in the module 'django.contrib.comments.feeds.comments' The user would install the feed with the code
feedconfig.register_feed_modules( ("django.contrib.comments.feeds.comments", None), )
The wonderful thing is that if a developer doesn't like how the title is displayed in the comments feed config, they can create their own module somewhere and extend the comments feed configuration:
myproject/feeds.py: from django.contrib.comments.feeds import comments class MyLatestCommentsFeed(comments.LatestCommentsFeed): def get_item_title(self): title = comment.LatestCommentsFeed.get_item_title(self) return "My Comment Site:" + title somewhere in myproject/settings/main.py: ... feedconfig.register_feed_modules( ("django.contrib.comments.feeds.comments", None), ("myproject.feeds.my_feeds", None), ) ...
In this case, all the comments feeds are registered but because the second one is loaded second, it registers the custom feed under the same slug and overrides the class registered with feeds.comments
Please not that this is a prototype, although completely usable. I welcome any ideas to make it easier for developers.
comment:8 by , 19 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
comment:9 by , 19 years ago
Status: | new → assigned |
---|
comment:10 by , 19 years ago
comment:11 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
(In [1194]) Completely refactored legacy RSS framework to the new django.contrib.syndication package. Also added Atom support, changed the way feeds are registered and added documentation for the whole lot. This is backwards-incompatible, but the RSS framework had not yet been documented, so this should only affect tinkerers and WorldOnline. Fixes #329, #498, #502 and #554. Thanks for various patches/ideas to alastair, ismael, hugo, eric moritz and garthk
comment:12 by , 18 years ago
Type: | enhancement → defect |
---|
Mind if I keep wading into it? I'd also like to modify links, add namespace support, and tackle a few other minor issues. I'll start maintaining it as a patch to the main code.