Merge lp:~mnordhoff/loggerhead/valid-feed into lp:loggerhead

Proposed by Matt Nordhoff
Status: Merged
Merged at revision: not available
Proposed branch: lp:~mnordhoff/loggerhead/valid-feed
Merge into: lp:loggerhead
Diff against target: None lines
To merge this branch: bzr merge lp:~mnordhoff/loggerhead/valid-feed
Reviewer Review Type Date Requested Status
Martin Albisetti Approve
Review via email: mp+7146@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Matt Nordhoff (mnordhoff) wrote :

This makes the Atom feed valid (bug #247162).

There's still one warning left because the URLs used in the <id>s are URL-encoded, so they're not in the "canonical form". I don't know what should be done, and it's just a warning, so it's probably not vital. Anyway, I'm not making it any *worse*.

At least I fixed all of the outright errors.

"change" objects store only the commit time, in local time, with no time zone information, while Atom feeds need a time + time zone. (See bug #376842.) As a simple, non-invasive and slightly evil solution, I just added a "utc_date" attribute and use UTC time in the feed. There are better fixes available, but it would be more complicated, and dealing with time zones makes my brain hurt, so this is all you're going to get from me any time soon. :P

lp:~mnordhoff/loggerhead/valid-feed updated
353. By Matt Nordhoff

Syntax (whitespace) tweak

Revision history for this message
Martin Albisetti (beuno) wrote :

Looks good, go ahead and merge.

review: Approve

Updating diff...

An updated diff will be available in a few minutes. Reload to see the changes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2009-06-05 01:59:11 +0000
3+++ NEWS 2009-06-06 09:26:45 +0000
4@@ -124,6 +124,8 @@
5
6 - Fix logging 404 Not Found responses (Matt Nordhoff, #381029)
7
8+ - Make sure the Atom feeds (nearly) validate. (Matt Nordhoff, #247162)
9+
10 1.10 [22Dec2008]
11 ---------------
12
13
14=== modified file 'loggerhead/controllers/atom_ui.py'
15--- loggerhead/controllers/atom_ui.py 2008-12-05 18:52:44 +0000
16+++ loggerhead/controllers/atom_ui.py 2009-06-06 09:09:55 +0000
17@@ -35,6 +35,6 @@
18 headers['Content-Type'] = 'application/atom+xml'
19 return {
20 'changes': entries,
21- 'updated': entries[0].date.isoformat() + 'Z',
22+ 'updated': entries[0].utc_date.isoformat(),
23 'history': self._history,
24 }
25
26=== modified file 'loggerhead/history.py'
27--- loggerhead/history.py 2009-05-28 22:48:45 +0000
28+++ loggerhead/history.py 2009-06-06 09:16:19 +0000
29@@ -660,8 +660,6 @@
30 Given a bzrlib Revision, return a processed "change" for use in
31 templates.
32 """
33- commit_time = datetime.datetime.fromtimestamp(revision.timestamp)
34-
35 parents = [util.Container(revid=r,
36 revno=self.get_revno(r)) for r in revision.parent_ids]
37
38@@ -674,7 +672,8 @@
39
40 entry = {
41 'revid': revision.revision_id,
42- 'date': commit_time,
43+ 'date': datetime.datetime.fromtimestamp(revision.timestamp),
44+ 'utc_date': datetime.datetime.utcfromtimestamp(revision.timestamp),
45 'authors': authors,
46 'branch_nick': revision.properties.get('branch-nick', None),
47 'short_comment': short_message,
48
49=== modified file 'loggerhead/templates/atom.pt'
50--- loggerhead/templates/atom.pt 2009-03-06 09:57:54 +0000
51+++ loggerhead/templates/atom.pt 2009-06-06 09:25:53 +0000
52@@ -3,17 +3,19 @@
53 <title>
54 bazaar changes for <tal:branch-name content="branch/friendly_name">branch name</tal:branch-name>
55 </title>
56- <updated tal:content="updated">${updated}</updated>
57+ <updated tal:content="string:${updated}Z">${updated}</updated>
58 <id tal:content="python:branch.url(['/atom'])">url</id>
59- <link rel="self" tal:attributes="href python:branch.url([''])" />
60+ <link rel="self" type="application/atom+xml" tal:attributes="href python:branch.url(['/atom'])" />
61+ <link rel="alternate" type="text/html" tal:attributes="href python:branch.url(['/changes'])" />
62
63 <entry tal:repeat="entry changes">
64 <title tal:content="string: ${entry/revno}: ${entry/short_comment}">
65 ${entry/revno}: ${entry/short_comment}
66 </title>
67- <updated tal:content="entry/date/isoformat">
68- Z
69+ <updated tal:content="string: ${entry/utc_date/isoformat}Z">
70+ updated
71 </updated>
72+ <!-- TODO: The feed validator will generate warnings because this is URL-encoded -->
73 <id tal:content="python:branch.url(['/revision', entry.revno])">
74 ID
75 </id>
76@@ -25,7 +27,7 @@
77 <content type="text" tal:content="entry/comment">
78 comment
79 </content>
80- <link rel="alternate"
81+ <link rel="alternate" type="text/html"
82 tal:attributes="href python:branch.url(['/revision', entry.revno])" />
83 </entry>
84 </feed>

Subscribers

People subscribed via source and target branches