# HG changeset patch # User Nicolas Chauvat # Date 1307608354 -7200 # Node ID 9e213becdcf47069f13aa3ba9fe4408459ee63d5 # Parent 4be45b64d75572d43322a34105b230a83d138009 [parsers] improve url construction by using stdlib's urllib instead of str concatenation fix a s/_/-/ bug on the way. diff -r 4be45b64d755 -r 9e213becdcf4 sobjects/parsers.py --- a/sobjects/parsers.py Thu Jun 09 10:37:01 2011 +0200 +++ b/sobjects/parsers.py Thu Jun 09 10:32:34 2011 +0200 @@ -33,6 +33,7 @@ import os.path as osp from datetime import datetime, timedelta +import urllib from logilab.common.date import todate, totime from logilab.common.textutils import splitstrip, text_to_dict @@ -304,10 +305,11 @@ try: return self._parsed_urls[(item['cwuri'], add_relations)] except KeyError: - itemurl = item['cwuri'] + '?vid=xml' + query = [('vid','xml')] if add_relations: for rtype, role, _ in self.source.mapping.get(item['cwtype'], ()): - itemurl += '&relation=%s_%s' % (rtype, role) + query.append(('relation','%s-%s' % (rtype, role))) + itemurl = item['cwuri'] + '?' + urllib.urlencode(query) item_rels = list(self.parse(itemurl)) assert len(item_rels) == 1, 'url %s expected to bring back one '\ 'and only one entity, got %s' % (itemurl, len(item_rels))