From 6f7eddf0f0d581c9b2fad2b5cb6004e92d706f54 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Wed, 27 Dec 2006 15:37:16 -0500 Subject: [PATCH] Allow one to subscribe to planet feeds --- planet/reconstitute.py | 8 +++++--- planet/splice.py | 4 +++- tests/data/reconstitute/source_planet_id.xml | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 tests/data/reconstitute/source_planet_id.xml diff --git a/planet/reconstitute.py b/planet/reconstitute.py index e2707e6..51f21c7 100644 --- a/planet/reconstitute.py +++ b/planet/reconstitute.py @@ -262,10 +262,12 @@ def reconstitute(feed, entry): # 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 + for name,value in feed.feed.items(): + if name.startswith('planet_'): src[name]=value + if feed.feed.has_key('id'): + src['planet_id'] = feed.feed.id else: - src = feed.feed + src = feed.feed # source:author src_author = src.get('author_detail',{}) diff --git a/planet/splice.py b/planet/splice.py index 4853619..750040d 100644 --- a/planet/splice.py +++ b/planet/splice.py @@ -81,7 +81,9 @@ def splice(): if sources: ids = sources[0].getElementsByTagName('id') if ids and ids[0].childNodes[0].nodeValue not in sub_ids: - continue + ids = sources[0].getElementsByTagName('planet_id') + if not ids: continue + if ids[0].childNodes[0].nodeValue not in sub_ids: continue # add entry to feed feed.appendChild(entry.documentElement) diff --git a/tests/data/reconstitute/source_planet_id.xml b/tests/data/reconstitute/source_planet_id.xml new file mode 100644 index 0000000..71ec1c0 --- /dev/null +++ b/tests/data/reconstitute/source_planet_id.xml @@ -0,0 +1,14 @@ + + + + http://example.com/ + + + http://example.org/ + + + +