Commit 316a1afe authored by Sam Ruby's avatar Sam Ruby

Ensure planet information makes it into the source element

parent c20acf99
......@@ -250,6 +250,7 @@ def reconstitute(feed, entry):
entry['%s_%s' % (ns,name)])
xoriglink.setAttribute('xmlns:%s' % ns, feed.namespaces[ns])
# author / contributor
author_detail = entry.get('author_detail',{})
if author_detail and not author_detail.has_key('name') and \
feed.feed.has_key('planet_name'):
......@@ -258,14 +259,24 @@ def reconstitute(feed, entry):
for contributor in entry.get('contributors',[]):
author(xentry, 'contributor', contributor)
xsource = xdoc.createElement('source')
src = entry.get('source') or feed.feed
# merge in planet:* from feed (or simply use the feed if no source)
src = entry.get('source')
if src:
for name,value in feed.feed.items():
if name.startswith('planet_'): src[name]=value
else:
src = feed.feed
# source:author
src_author = src.get('author_detail',{})
if (not author_detail or not author_detail.has_key('name')) and \
not src_author.has_key('name') and feed.feed.has_key('planet_name'):
if src_author: src_author = src_author.__class__(src_author.copy())
src['author_detail'] = src_author
src_author['name'] = feed.feed['planet_name']
# source
xsource = xdoc.createElement('source')
source(xsource, src, bozo, feed.version)
xentry.appendChild(xsource)
......
<!--
Description: planet name
Expect: source.planet_name == 'John Doe'
-->
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:planet="http://planet.intertwingly.net/">
<planet:name>John Doe</planet:name>
<entry/>
</feed>
<!--
Description: ensure that planet attributes make it into the source
Expect: source.planet_name == 'John Doe'
-->
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:planet="http://planet.intertwingly.net/">
<planet:name>John Doe</planet:name>
<entry>
<source>
<id>http://example.com/</id>
</source>
</entry>
</feed>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment