Permalink
Browse files

added collection feed support

git-svn-id: http://django-atompub.googlecode.com/svn/trunk@44 7eb3654f-6a36-0410-9a19-79f10952aee7
  • Loading branch information...
1 parent 85e47fb commit 1dad7f30fe5201072ecfce71dad6a7029affe65a @jtauber committed Sep 15, 2007
Showing with 46 additions and 0 deletions.
  1. +39 −0 atompub/protocol/feeds.py
  2. +7 −0 atompub/urls.py
View
@@ -0,0 +1,39 @@
+from atompub.atom import Feed
+
+from atompub.protocol.models import Collection
+
+
+class CollectionFeed(Feed):
+
+ def get_object(self, params):
+ if len(params) != 1:
+ raise LookupError
+ return Collection.objects.get(id=params[0])
+
+ def feed_id(self, obj):
+ return obj.href()
+
+ def feed_title(self, obj):
+ return obj.title
+
+ def items(self, obj):
+ # @@@ returns all for now
+ return obj.memberentry_set.order_by("-edited")
+
+ def item_id(self, item):
+ return item.href()
+
+ def item_title(self, item):
+ return item.title
+
+ def item_updated(self, item):
+ return item.edited # @@@ for now
+
+ def item_authors(self, item):
+ return [{"name": item.creator.get_full_name()}]
+
+ def item_links(self, item):
+ return [
+ {"href": item.href()},
+ {"rel": "edit", "href": item.href()}
+ ]
View
@@ -1,13 +1,20 @@
from django.conf.urls.defaults import *
from atompub.protocol.views import service
+from atompub.protocol.feeds import CollectionFeed
from atompub.testmodel.feeds import TestFeed1, TestFeed2, TestFeed3, TestFeed4
urlpatterns = patterns('',
(r"^service/$", service),
+ (r"^(collection/\d+)/$", "django.contrib.syndication.views.feed", {
+ "feed_dict": {
+ "collection": CollectionFeed,
+ }
+ }),
+
# for testing
(r"^feeds/(.*)/$", "django.contrib.syndication.views.feed", {
"feed_dict": {

0 comments on commit 1dad7f3

Please sign in to comment.