--- a/sobjects/parsers.py Tue Jul 26 10:33:26 2011 +0200
+++ b/sobjects/parsers.py Tue Jul 26 11:01:17 2011 +0200
@@ -178,8 +178,10 @@
def process(self, url, raise_on_error=False, partialcommit=True):
"""IDataFeedParser main entry point"""
- super(CWEntityXMLParser, self).process(self.complete_url(url),
- raise_on_error, partialcommit)
+ if url.startswith('http'): # XXX similar loose test as in parse of sources.datafeed
+ url = self.complete_url(url)
+ super(CWEntityXMLParser, self).process(url, raise_on_error, partialcommit)
+
def parse_etree(self, parent):
for node in list(parent):
builder = self._cw.vreg['components'].select(
@@ -226,24 +228,25 @@
be included in the resulting xml, according to source mapping.
If etype is not specified, try to guess it using the last path part of
- the url.
+ the url, i.e. the format used by default in cubicweb to map all entities
+ of a given type as in 'http://mysite.org/EntityType'.
"""
try:
url, qs = url.split('?', 1)
except ValueError:
qs = ''
+ params = parse_qs(qs)
+ if not 'vid' in params:
+ params['vid'] = ['xml']
if etype is None:
try:
etype = url.rsplit('/', 1)[1]
except ValueError:
- return url
+ return url + '?' + self._cw.build_url_params(**params)
try:
etype = self._cw.vreg.case_insensitive_etypes[etype]
except KeyError:
- return url
- params = parse_qs(qs)
- if not 'vid' in params:
- params['vid'] = ['xml']
+ return url + '?' + self._cw.build_url_params(**params)
if add_relations:
relations = params.setdefault('relation', [])
for rtype, role, _ in self.source.mapping.get(etype, ()):
--- a/sobjects/test/unittest_parsers.py Tue Jul 26 10:33:26 2011 +0200
+++ b/sobjects/test/unittest_parsers.py Tue Jul 26 11:01:17 2011 +0200
@@ -144,6 +144,10 @@
'http://www.cubicweb.org/cwuser?relation=tags-object&relation=in_group-subject&relation=in_state-subject&relation=use_email-subject&vid=xml')
self.assertEqual(parser.complete_url('http://www.cubicweb.org/cwuser?vid=rdf&relation=hop'),
'http://www.cubicweb.org/cwuser?relation=hop&relation=tags-object&relation=in_group-subject&relation=in_state-subject&relation=use_email-subject&vid=rdf')
+ self.assertEqual(parser.complete_url('http://www.cubicweb.org/?rql=cwuser&vid=rdf&relation=hop'),
+ 'http://www.cubicweb.org/?rql=cwuser&relation=hop&vid=rdf')
+ self.assertEqual(parser.complete_url('http://www.cubicweb.org/?rql=cwuser&relation=hop'),
+ 'http://www.cubicweb.org/?rql=cwuser&relation=hop&vid=xml')
def test_actions(self):