Opened 6 years ago

Closed 12 months ago

Last modified 9 months ago

#13110 closed New feature (fixed)

Allow multiple enclosures in Atom feeds

Reported by: Piaume Owned by: unaizalakain
Component: contrib.syndication Version: master
Severity: Normal Keywords: multiple, enclosures, atom, feed 1.9
Cc: kotenko@…, unai@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

For now, Feed.item_enclosure_url represents a single enclosure for an item. It should be nice to support many enclosures per item. Something like that:

class ExampleFeed(Feed):
    def item_enclosure_url(self, item):
        return [video.url for video in item.videos]

Change History (24)

comment:1 Changed 6 years ago by ericholscher

  • milestone changed from 1.2 to 1.3
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Feature Request.

comment:2 Changed 6 years ago by russellm

  • milestone 1.3 deleted
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 6 years ago by jasonkotenko

  • Cc kotenko@… added
  • Needs documentation set
  • Needs tests set
  • Owner changed from nobody to jasonkotenko
  • Status changed from new to assigned

comment:4 Changed 6 years ago by jasonkotenko

  • Triage Stage changed from Accepted to Design decision needed

It appears that RSS only officially supports one enclosure per item {1}, and Atom supports multiple. Since RSS is the default feed, actually the use case presented in the bug report is invalid. The question then becomes, should we support multiple enclosures for Atom? As of now the enclosure is handled in the same general way in both types of feeds.

Changing to "Design Decision Needed" before I do anything else... Please let me know if that was the wrong thing to do in this situation, as I'm pretty new to the Django community.

{1} - http://www.rssboard.org/rss-profile#element-channel-item-enclosure

comment:5 Changed 5 years ago by lukeplant

  • Type set to New feature

comment:6 Changed 5 years ago by lukeplant

  • Severity set to Normal

comment:7 follow-up: Changed 5 years ago by aaugustin

  • Easy pickings unset
  • Triage Stage changed from Design decision needed to Accepted
  • UI/UX unset

It should be possible to accept either a string or a list of string, and to validate that there's only one enclosure for RSS feeds.

comment:8 in reply to: ↑ 7 Changed 13 months ago by unaizalakain

Replying to aaugustin:

It should be possible to accept either a string or a list of string, and to validate that there's only one enclosure for RSS feeds.

Currently Feed builds the Enclosure from item_enclosure_url, item_enclosure_length and item_enclosure_mime_type. Accepting an optional list for one of them would mean accepting optional lists for the three of them and that would become quite a strange and cumbersome API.

Instead, I propose creating a item_enclosures attr/func (the same way all the other attr/funcs work) which, by default, returns a list with a single Enclosure in it. That enclosure would be built using the url, length and mime_type gotten from the corresponding attrs.

RSS feeds could then validate that item_enclosures is no longer than 1.

Last edited 13 months ago by unaizalakain (previous) (diff)

comment:9 Changed 12 months ago by unaizalakain

  • Cc unai@… added
  • Has patch set
  • Keywords multiple enclosures atom feed added
  • Owner changed from jasonkotenko to unaizalakain
  • Version changed from 1.1 to master

comment:11 Changed 12 months ago by unaizalakain

I updated the commit with the proposed changes and opened a PR:
https://github.com/django/django/pull/5200

comment:12 Changed 12 months ago by MarkusH

  • Patch needs improvement set

comment:13 Changed 12 months ago by unaizalakain

  • Needs documentation unset
  • Patch needs improvement unset

Updated PR with docs.

comment:14 Changed 12 months ago by unaizalakain

  • Needs tests unset

Basic tests added, PR updated, ready for review!

comment:15 Changed 12 months ago by timgraham

  • Patch needs improvement set
  • Summary changed from Multiple enclosures per feed's item to Allow multiple enclosures in Atom feeds

I left comments for improvement on the pull request.

comment:16 Changed 12 months ago by unaizalakain

  • Patch needs improvement unset

PR updated!

comment:17 Changed 12 months ago by timgraham

  • Triage Stage changed from Accepted to Ready for checkin

comment:18 Changed 12 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In aac2a2d:

Fixed #13110 -- Added support for multiple enclosures in Atom feeds.

The item_enclosures hook returns a list of Enclosure objects which is
then used by the feed builder. If the feed is a RSS feed, an exception is
raised as RSS feeds don't allow multiple enclosures per feed item.

The item_enclosures hook defaults to an empty list or, if the
item_enclosure_url hook is defined, to a list with a single Enclosure
built from the item_enclosure_url, item_enclosure_length, and
item_enclosure_mime_type hooks.

comment:19 Changed 12 months ago by timgraham

  • Has patch unset
  • Keywords 1.9 added
  • Resolution fixed deleted
  • Status changed from closed to new
  • Triage Stage changed from Ready for checkin to Accepted

Reopening per comments on the commit.

comment:20 Changed 12 months ago by unaizalakain

  • Has patch set

Sorry about that…
New PR: https://github.com/django/django/pull/5315

comment:21 Changed 12 months ago by Unai Zalakain <unai@…>

In a4b80e24:

Refs #13110 -- Fixed mistakes in the new multiple enclosure feed tests

comment:22 Changed 12 months ago by timgraham

  • Resolution set to fixed
  • Status changed from new to closed

comment:23 Changed 9 months ago by Tim Graham <timograham@…>

In 2ec23a3d:

Refs #13110 -- Fixed typo in Feed class reference.

comment:24 Changed 9 months ago by Tim Graham <timograham@…>

In 54295a95:

[1.9.x] Refs #13110 -- Fixed typo in Feed class reference.

Backport of 2ec23a3d41be2ba5df9f46b17e0a05eb1b051c41 from master

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