sobjects/parsers.py
branchstable
changeset 7689 a86fd3ec322e
parent 7553 935423529f45
child 7700 0010dde5352a
--- 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, ()):