Opened 17 years ago

Closed 16 years ago

Last modified 13 years ago

#6547 closed (fixed)

Support GeoRSS in syndication of Geographic Models

Reported by: jbronn Owned by: jbronn
Component: GIS Version: gis
Severity: Keywords: gis georss feed rss
Cc: jbronn@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by jbronn)

There should be a django.contrib.gis.syndication module, that will contain a subclass of Feed, that will include GeoRSS information for geographic models.

GeoRSS support for Django was discussed earlier in django-users. The solution should be simple, and be familiar to those who have used Django's syndication feeds -- in other words, keep the API consistent with what Django already has. See also [browser:django/trunk/django/utils/feedgenerator.py].

Attachments (4)

georss_syndication_patch.diff (12.4 KB ) - added by jbronn 16 years ago.
Patch for GeoRSS; also includes some internal changes to Feed
georss_syndication_patch_v2.diff (13.0 KB ) - added by jbronn 16 years ago.
Version 2; uses W3C Geo for RSS points.
georss_syndication_patch_v3.diff (15.0 KB ) - added by jbronn 16 years ago.
W3C Geo is no longer default for points on RSS feeds, but is now its own subclass.
georss_syndication_patch_v4.diff (7.3 KB ) - added by jbronn 16 years ago.
Less intrusive patch to contrib.syndication.

Download all attachments as: .zip

Change History (17)

comment:1 by jbronn, 17 years ago

Triage Stage: UnreviewedAccepted

comment:2 by jbronn, 17 years ago

Description: modified (diff)

comment:3 by hanne.moa@…, 16 years ago

There's no need to limit this to only GeoDjango. All that's needed is to add item_location to the base SyndicationFeed that adds a location (tuple?) to item, then change the syndictation-types to spit out a <georss:point>-line if item has a location.

Then pepole would override item_location in the exact same way they already do for links, authors, categories etc.

Now if growing feeds by adding extra xml-tags becomes common, there should probably be a generic way of adding such tags, especially if they are as undemanding as georss.

comment:4 by jbronn, 16 years ago

milestone: 1.0 beta
Status: newassigned

comment:5 by Robert Coup, 16 years ago

I looked at this a bit tonight (because I want to generate some GeoRSS feeds)... comments are below. Mostly referring to Atom but similar concepts apply to RSS - noted in (brackets):

  • creating a subclass of django.contrib.syndication.feeds.Feed with item_location and location parameters won't be a problem to extract a geometry field from a model
  • the problem comes with respect to django.utils.feedgenerator.SyndicationFeed:
    • we want to add a <georss:where> clause to the feed(channel), each entry(item), or both.
    • we need to add the georss namespace declaration to <feed> (<channel>)
    • there are no hooks for extending either the feed or the entry, which means we'd have to reimplement/duplicate the entire write() and write_items() for each feed format. :(

Ok, so that's not gonna happen.

Extensions I think should be added to SyndicationFeed & its implementations to allow us to GeoRSS-ify stuff:

  • SyndicationFeed.__init__() and SyndicationFeed.add_item() should take kwargs which are added into the feed/item dictionaries respectively.
  • extra_attrs(): Add attributes to the root feed(channel) element. eg. xmlns:georss="http://...". Returns a dictionary. Called from write()
  • extras(handler): Add elements within the feed(channel) element. eg. a <georss:where> for the feed. Called from write()
  • item_extra_attrs(item): Add attributes to the entry(item) elements (called once for each item). Returns a dictionary. Called from write_items()
  • item_extras(handler, item): Add elements within the entry(item) elements (called once for each item). Would be where the georss would be added. Called from write_items()

Once we have those hooks we can do a mixin with each of the existing SyndicationFeed implementations and a GeoRSS implementation that knows how to turn a geometry object into a suitable GeoRSS clause. It would not just do georss then, but could also do media: or any other extensions. Thats quite a sizeable set of changes though, so I guess we need to bring it up on django-dev, and who knows whether it'll get through pre-1.0. I think those hooks make things much more flexible without needing to go to the lengths of rewriting the whole framework.

See also:

Probably should be another ticket, but I thought i'd get some initial feedback first.

comment:6 by Jacob, 16 years ago

(In [8310]) Added a couple of extra syndication tests, and generally sanitized the existing ones. Refs #6547.

comment:7 by Jacob, 16 years ago

(In [8311]) Added a number of callbacks to SyndicationFeed for adding custom attributes and elements to feeds. Refs #6547.

comment:8 by Jacob, 16 years ago

OK, Justin, it's all you now.

comment:9 by Jacob, 16 years ago

milestone: 1.0 beta1.0

Now that [8311] and [8331] are in, there's no reason this needs to block the beta.

comment:10 by Robert Coup, 16 years ago

Awesome Jacob, I'll work up a patch for the GeoRSS bit :)

by jbronn, 16 years ago

Patch for GeoRSS; also includes some internal changes to Feed

comment:11 by jbronn, 16 years ago

In my patch I added django.contrib.gis.feeds.Feed, which has support for simple GeoRSS. You may specify a geometry element on the entire feed by defining a geometry function; similarly, geometries in the feed may be specified by item_geometry method -- both should return a WGS84 (GEOS|OGR)Geometry.

Some big internal changes to the original Feed class, specifically abstracting a lot to the (now) subclassable get_feed_kwargs and get_item_kwargs methods. Tests pass, but I want some input on whether it's OK to make some of those variables class-wide (e.g., self.current_site, and the templates). This makes subclassing Feed easier, granting access to the __get_dynamic_attr magic.

by jbronn, 16 years ago

Version 2; uses W3C Geo for RSS points.

by jbronn, 16 years ago

W3C Geo is no longer default for points on RSS feeds, but is now its own subclass.

by jbronn, 16 years ago

Less intrusive patch to contrib.syndication.

comment:12 by jbronn, 16 years ago

Resolution: fixed
Status: assignedclosed

(In [8414]) Fixed #6547, added support for GeoRSS feeds in django.contrib.gis.feeds; added the feed_extra_kwargs and item_extra_kwargs to the Feed baseclass so that it's possible for subclasses to add dynamic attributes.

comment:13 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top