[cw source ui] fix mapping checking for datafeed source (avoid false positive error, but doesn't check that much things) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 13 May 2011 10:09:52 +0200
branchstable
changeset 7375 c8a8fb32733b
parent 7374 3c9850d929e5
child 7376 38524ca653e5
[cw source ui] fix mapping checking for datafeed source (avoid false positive error, but doesn't check that much things)
web/views/cwsources.py
--- a/web/views/cwsources.py	Thu May 12 10:22:17 2011 +0200
+++ b/web/views/cwsources.py	Fri May 13 10:09:52 2011 +0200
@@ -126,6 +126,8 @@
         else: # CWAttribute/CWRelation
             self.srelations.setdefault(cwerschema.rtype.name, []).append(
                 (cwerschema.stype.name, cwerschema.otype.name) )
+            self.sentities.add(cwerschema.stype.name)
+            self.sentities.add(cwerschema.otype.name)
 
     def check(self):
         self.init()
@@ -154,14 +156,15 @@
                     warning(_('relation %(rtype)s with %(etype)s as %(role)s is '
                               'supported but no target type supported') %
                             {'rtype': rschema, 'role': role, 'etype': etype})
-        for rtype in self.srelations:
-            rschema = self.schema[rtype]
-            for subj, obj in rschema.rdefs:
-                if subj in self.sentities and obj in self.sentities:
-                    break
-            else:
-                error(_('relation %s is supported but none if its definitions '
-                        'matches supported entities') % rtype)
+        for rtype, rdefs in self.srelations.iteritems():
+            if rdefs is None:
+                rschema = self.schema[rtype]
+                for subj, obj in rschema.rdefs:
+                    if subj in self.sentities and obj in self.sentities:
+                        break
+                else:
+                    error(_('relation %s is supported but none of its definitions '
+                            'matches supported entities') % rtype)
         self.custom_check()
 
     def custom_check(self):