Opened 7 years ago

Closed 5 years ago

Last modified 4 years ago

#6039 closed (fixed)

ATOM feed example is bogus

Reported by: ion.morega@… Owned by: stugots
Component: Documentation Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The example code at the end of the syndication_feeds documentation page has a couple of problems that I discovered while trying to get the feed validator to accept my ATOM 1.0 feed:

The encoding "utf8" is invalid; it should be "utf-8".

An author name must be specified, either for the feed itself or for each entry - the author_name parameter.

The feed document must have a self link; this is set using the feed_url parameter when constructing the feed object.

I'm attaching the example code, modified with the above suggestions. Note that I added a few line breaks in the output of the script, to prevent exceedingly long lines.

Attachments (4)

atom_feed.txt (1.1 KB) - added by Ion Morega <ion.morega@…> 7 years ago.
sample code that generates a valid ATOM feed
worksforme.GIF (50.7 KB) - added by stugots 7 years ago.
6039.patch (67.2 KB) - added by stugots 7 years ago.
Patch for this ticket.
atom-feed.diff (1.2 KB) - added by arien 7 years ago.
patch against r8972

Download all attachments as: .zip

Change History (20)

Changed 7 years ago by Ion Morega <ion.morega@…>

sample code that generates a valid ATOM feed

comment:1 Changed 7 years ago by Simon G <dev@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 years ago by anonymous

  • Owner changed from nobody to anonymous
  • Status changed from new to assigned

comment:3 Changed 7 years ago by stugots

  • Owner changed from anonymous to stugots
  • Status changed from assigned to new

comment:4 Changed 7 years ago by stugots

  • Status changed from new to assigned

comment:5 Changed 7 years ago by stugots

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

I hope I'm doing this right -- this is the first Django ticket I've ever claimed.

I cannot reproduce your bug, using Python 2.5.1 and Django [7091], running on Windows XP.

I'm attaching a screenshot of my command window. I typed in the text at the bottom of http://www.djangoproject.com/documentation/syndication_feeds/, except for a shorter feed description attribute. And f.writeString() ran fine -- it accepted both 'utf8' or 'utf-8' for an encoding.

Perhaps feedgenerator changed since you opened this bug?

If the bug is still happening for you, then reopen this ticket. Thanks!

Changed 7 years ago by stugots

comment:6 Changed 7 years ago by Ion Morega <ion.morega@…>

  • Resolution worksforme deleted
  • Status changed from closed to reopened

You are correct - the code does work, and produces the output you observed. But the problem is about producing *valid* ATOM feeds.

What I did was take the output of django.utils.feedgenerator, serve it via http, and verify it with http://feedvalidator.org/. In short, feedvalidator.org produces errors with the output in the documentation, and produces no errors after my modifications.

If you like, I can set up a small test server and serve both files so you can see the feedvalidator's output.

comment:7 Changed 7 years ago by stugots

Duh! Sorry for misreading your problem report!

Thanks for the server offer, I'll let you know if I need that. I'll take a proper crack at this tomorrow.

comment:8 Changed 7 years ago by stugots

  • Has patch set

Attaching a patch for this ticket, in 6039.patch.

Changed 7 years ago by stugots

Patch for this ticket.

comment:9 Changed 7 years ago by stugots

Ugh, that's ugly. I generated the patch on a Windows system, and the line endings must be different. I'll see if I can generate a shorter patch. The only lines I changed were the "Example Usage" section near the file's end.

comment:10 Changed 7 years ago by stugots

[6545] refers to the line-ending problem with pool text files.

I couldn't find a way to make SVN do the right thing with the line-endings while generating the .patch file. Proposal to whomever evaluates this for check-in: Apply the patch on a *nix or Mac system, and then diff the result. You'll see I changed only the lines at the end of the file.

comment:11 Changed 7 years ago by stugots

That should be #6545, not [6545].

Changed 7 years ago by arien

patch against r8972

comment:12 Changed 7 years ago by arien

The output produced after applying the patch is a valid feed, as long as you assume the feed is located at http://www.example.com/atom.xml. This can be easily verified using the feedvalidator. (For example, running python src/demo.py /path/to/output.xml.)

comment:13 Changed 5 years ago by Rupe

  • milestone set to 1.2

Can this be included?

comment:14 Changed 5 years ago by russellm

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

(In [13179]) Fixed #6039 -- Modified Atom example to be standard compliant. Thanks to ion.morega@… for the report, and arien for the patch.

comment:15 Changed 5 years ago by russellm

(In [13181]) [1.1.X] Fixed #6039 -- Modified Atom example to be standard compliant. Thanks to ion.morega@… for the report, and arien for the patch.

Backport of r13179 from trunk.

comment:16 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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