summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Ruby <rubys@intertwingly.net>2011-02-07 14:01:22 -0500
committerSam Ruby <rubys@intertwingly.net>2011-02-07 14:01:22 -0500
commit70810fff6a8f43c81892369c53294eb77fc79ad6 (patch)
treeb2c9039ecd7d04154b39b29f961c0a5c22d1f34b
parentfe126bf3ea38538683e13e41e50af7a7fd7ad7e1 (diff)
downloadplanetpixels-70810fff6a8f43c81892369c53294eb77fc79ad6.tar.gz
planetpixels-70810fff6a8f43c81892369c53294eb77fc79ad6.tar.bz2
Fix for Google Reader Shared Feeds:
http://lists.planetplanet.org/archives/devel/2011-February/002196.html
-rw-r--r--planet/reconstitute.py1
-rw-r--r--planet/spider.py4
-rw-r--r--tests/data/reconstitute/gr_id.xml11
3 files changed, 15 insertions, 1 deletions
diff --git a/planet/reconstitute.py b/planet/reconstitute.py
index ffba7a0..bb41cfa 100644
--- a/planet/reconstitute.py
+++ b/planet/reconstitute.py
@@ -70,6 +70,7 @@ def id(xentry, entry):
if entry.has_key("id") and entry.id:
entry_id = entry.id
+ if hasattr(entry_id, 'values'): entry_id = entry_id.values()[0]
elif entry.has_key("link") and entry.link:
entry_id = entry.link
elif entry.has_key("title") and entry.title:
diff --git a/planet/spider.py b/planet/spider.py
index 311077f..50d1739 100644
--- a/planet/spider.py
+++ b/planet/spider.py
@@ -176,7 +176,9 @@ def writeCache(feed_uri, feed_info, data):
# generate an id, if none is present
if not entry.has_key('id') or not entry.id:
entry['id'] = reconstitute.id(None, entry)
- if not entry['id']: continue
+ elif hasattr(entry['id'], 'values'):
+ entry['id'] = entry['id'].values()[0]
+ if not entry['id']: continue
# determine updated date for purposes of selection
updated = ''
diff --git a/tests/data/reconstitute/gr_id.xml b/tests/data/reconstitute/gr_id.xml
new file mode 100644
index 0000000..eca22b7
--- /dev/null
+++ b/tests/data/reconstitute/gr_id.xml
@@ -0,0 +1,11 @@
+<!--
+Description: id
+Expect: id == 'http://example.com/2'
+-->
+
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <entry xmlns:gr="http://www.google.com/schemas/reader/atom/">
+ <id gr:original-id="http://example.com/2">http://example.com/1</id>
+ </entry>
+</feed>
+