Django

Code

Ticket #6547 (closed: fixed)

Opened 10 months ago

Last modified 4 months ago

Support GeoRSS in syndication of Geographic Models

Reported by: jbronn Assigned to: jbronn
Milestone: 1.0 Component: GIS
Version: gis Keywords: gis georss feed rss
Cc: jbronn@gmail.com Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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 django/trunk/django/utils/feedgenerator.py.

Attachments

georss_syndication_patch.diff (12.4 kB) - added by jbronn on 08/12/08 23:13:58.
Patch for GeoRSS; also includes some internal changes to Feed
georss_syndication_patch_v2.diff (13.0 kB) - added by jbronn on 08/13/08 19:49:12.
Version 2; uses W3C Geo for RSS points.
georss_syndication_patch_v3.diff (15.0 kB) - added by jbronn on 08/14/08 15:34:48.
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 on 08/15/08 13:24:26.
Less intrusive patch to contrib.syndication.

Change History

02/04/08 09:04:09 changed by jbronn

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

02/04/08 09:12:50 changed by jbronn

  • description changed.

06/29/08 18:26:28 changed by hanne.moa@gmail.com

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.

07/01/08 13:31:01 changed by jbronn

  • status changed from new to assigned.
  • milestone set to 1.0 beta.

07/11/08 06:11:17 changed by rcoup

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.

08/11/08 15:49:19 changed by jacob

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

08/11/08 17:22:28 changed by jacob

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

08/11/08 17:24:02 changed by jacob

OK, Justin, it's all you now.

08/12/08 17:13:15 changed by jacob

  • milestone changed from 1.0 beta to 1.0.

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

08/12/08 17:34:03 changed by rcoup

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

08/12/08 23:13:58 changed by jbronn

  • attachment georss_syndication_patch.diff added.

Patch for GeoRSS; also includes some internal changes to Feed

08/12/08 23:28:33 changed by jbronn

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.

08/13/08 19:49:12 changed by jbronn

  • attachment georss_syndication_patch_v2.diff added.

Version 2; uses W3C Geo for RSS points.

08/14/08 15:34:48 changed by jbronn

  • attachment georss_syndication_patch_v3.diff added.

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

08/15/08 13:24:26 changed by jbronn

  • attachment georss_syndication_patch_v4.diff added.

Less intrusive patch to contrib.syndication.

08/16/08 15:40:47 changed by jbronn

  • status changed from assigned to closed.
  • resolution set to fixed.

(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.


Add/Change #6547 (Support GeoRSS in syndication of Geographic Models)




Change Properties
Action