# HG changeset patch # User Goffi # Date 1448974548 -3600 # Node ID 6d6eae4906819e635a3390f33604c3f81c5caba2 # Parent 94c450972346ae951f4be20c2efcc353ba335158 plugin XEP-0277: accept several elements, there is a standard issue so for now it's the most flexible behaviour diff -r 94c450972346 -r 6d6eae490681 src/plugins/plugin_xep_0277.py --- a/src/plugins/plugin_xep_0277.py Tue Dec 01 12:45:14 2015 +0100 +++ b/src/plugins/plugin_xep_0277.py Tue Dec 01 13:55:48 2015 +0100 @@ -207,14 +207,26 @@ microblog_data['atom_id'] = unicode(id_elt) # title/content(s) - try: - title_elt = entry_elt.elements(NS_ATOM, 'title').next() - except StopIteration: + + # FIXME: ATOM and XEP-0277 only allow 1 <title/> element + # but in the wild we have some blogs with several ones + # so we don't respect the standard for now (it doesn't break + # anything anyway), and we'll find a better option later + # try: + # title_elt = entry_elt.elements(NS_ATOM, 'title').next() + # except StopIteration: + # msg = u'No atom title found in the pubsub item {}'.format(id_) + # raise failure.Failure(exceptions.DataError(msg)) + title_elts = list(entry_elt.elements(NS_ATOM, 'title')) + if not title_elts: msg = u'No atom title found in the pubsub item {}'.format(id_) raise failure.Failure(exceptions.DataError(msg)) + for title_elt in title_elts: + yield parseElement(title_elt) - yield parseElement(title_elt) - + # FIXME: as for <title/>, Atom only authorise at most 1 content + # but XEP-0277 allows several ones. So for no we handle as + # if more than one can be present for content_elt in entry_elt.elements(NS_ATOM, 'content'): yield parseElement(content_elt)