[datafeed] properly take care to cwsource=system in imported xml. Closes #1877017 stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 26 Jul 2011 16:49:10 +0200
branchstable
changeset 7699 d07cde311630
parent 7698 1c7411535c2d
child 7700 0010dde5352a
[datafeed] properly take care to cwsource=system in imported xml. Closes #1877017
server/sources/datafeed.py
sobjects/test/unittest_parsers.py
--- a/server/sources/datafeed.py	Tue Jul 26 16:35:10 2011 +0200
+++ b/server/sources/datafeed.py	Tue Jul 26 16:49:10 2011 +0200
@@ -268,8 +268,11 @@
         # if cwsource is specified and repository has a source with the same
         # name, call extid2eid on that source so entity will be properly seen as
         # coming from this source
-        source = session.repo.sources_by_uri.get(
-            sourceparams.pop('cwsource', None), self.source)
+        source_uri = sourceparams.pop('cwsource', None)
+        if source_uri is not None and source_uri != 'system':
+            source = session.repo.sources_by_uri.get(source_uri, self.source)
+        else:
+            source = self.source
         sourceparams['parser'] = self
         try:
             eid = session.repo.extid2eid(source, str(uri), etype, session,
--- a/sobjects/test/unittest_parsers.py	Tue Jul 26 16:35:10 2011 +0200
+++ b/sobjects/test/unittest_parsers.py	Tue Jul 26 16:49:10 2011 +0200
@@ -40,7 +40,7 @@
 
 BASEXML = ''.join(u'''
 <rset size="1">
- <CWUser eid="5" cwuri="http://pouet.org/5">
+ <CWUser eid="5" cwuri="http://pouet.org/5" cwsource="system">
   <login>sthenault</login>
   <upassword>toto</upassword>
   <last_login_time>2011-01-25 14:14:06</last_login_time>
@@ -117,7 +117,12 @@
 </rset>
 '''.splitlines()
 )
+
+
 class CWEntityXMLParserTC(CubicWebTC):
+    """/!\ this test use a pre-setup database /!\, if you modify above xml,
+    REMOVE THE DATABASE TEMPLATE else it won't be considered
+    """
     test_db_id = 'xmlparser'
     @classmethod
     def pre_setup_database(cls, session, config):