[dataimport] make MetadataGenerator.META_RELATIONS customizable
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Mon, 17 Oct 2016 16:53:28 +0200
changeset 11779 9a3663ec4ead
parent 11778 9847a097266e
child 11780 307d96c0ab5a
[dataimport] make MetadataGenerator.META_RELATIONS customizable This should be done on the instance rather than on the class
cubicweb/dataimport/stores.py
--- a/cubicweb/dataimport/stores.py	Wed Sep 28 08:57:48 2016 +0200
+++ b/cubicweb/dataimport/stores.py	Mon Oct 17 16:53:28 2016 +0200
@@ -272,12 +272,12 @@
     * `baseurl`: optional base URL to be used for `cwuri` generation - default to config['base-url']
     * `source`: optional source to be used as `cw_source` for imported entities
     """
-    META_RELATIONS = (META_RTYPES
-                      - VIRTUAL_RTYPES
-                      - set(('eid', 'cwuri',
-                             'is', 'is_instance_of', 'cw_source')))
+    META_RELATIONS = frozenset(META_RTYPES
+                               - VIRTUAL_RTYPES
+                               - set(('eid', 'cwuri',
+                                      'is', 'is_instance_of', 'cw_source')))
 
-    def __init__(self, cnx, baseurl=None, source=None):
+    def __init__(self, cnx, baseurl=None, source=None, meta_skipped=()):
         self._cnx = cnx
         if baseurl is None:
             config = cnx.vreg.config
@@ -295,7 +295,8 @@
         # attributes/relations specific to each entity
         self._entity_attrs = ['cwuri']
         rschema = cnx.vreg.schema.rschema
-        for rtype in self.META_RELATIONS:
+        self.meta_relations = self.META_RELATIONS - set(meta_skipped)
+        for rtype in self.meta_relations:
             # skip owned_by / created_by if user is the internal manager
             if cnx.user.eid == -1 and rtype in ('owned_by', 'created_by'):
                 continue