[PATCH 1 of 5 saem_ref v2] Drop "rql" store from choices of "skos-import" command

Denis Laxalde denis.laxalde at logilab.fr
Mon Jan 8 15:05:57 CET 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1515402660 -3600
#      Mon Jan 08 10:11:00 2018 +0100
# Node ID 0140f2679535d889a3919194ba9253962cf83648
# Parent  fa989ea49877a4ce8d59b8ba9035b8e45c508ee7
# EXP-Topic lcsv-skos-import
Drop "rql" store from choices of "skos-import" command

RQLObjectStore is not supported in saem_ref because it cannot handle a
metadata generator which is needed in saem_ref to generate ARK
identifiers.

diff --git a/cubicweb_saem_ref/__init__.py b/cubicweb_saem_ref/__init__.py
--- a/cubicweb_saem_ref/__init__.py
+++ b/cubicweb_saem_ref/__init__.py
@@ -73,6 +73,6 @@ def _massive_store_factory(cnx, **kwargs
 
 
 def _nohook_store_factory(cnx):
-    from cubicweb.dataimport.stores import NoHooRQLObjectStore
+    from cubicweb.dataimport.stores import NoHookRQLObjectStore
     from .sobjects import SAEMMetadataGenerator
-    return NoHooRQLObjectStore(cnx, metagen=SAEMMetadataGenerator(cnx))
+    return NoHookRQLObjectStore(cnx, metagen=SAEMMetadataGenerator(cnx))
diff --git a/cubicweb_saem_ref/ccplugin.py b/cubicweb_saem_ref/ccplugin.py
--- a/cubicweb_saem_ref/ccplugin.py
+++ b/cubicweb_saem_ref/ccplugin.py
@@ -25,6 +25,7 @@ from cubicweb import MultipleResultsErro
 from cubicweb.toolsutils import underline_title
 from cubicweb.utils import admincnx
 
+from cubes.skos import ccplugin as skos
 from cubicweb_eac import ccplugin as eac
 
 from . import _massive_store_factory, _nohook_store_factory
@@ -41,6 +42,29 @@ eac.ImportEacData.options = (
 )
 
 
+def _skos_drop_rql_store():
+    """Remove "rql" store from ImportSkosData command.
+
+    "rql" store is not supported in saem_ref because it cannot handle a
+    metadata generator which is needed in saem_ref to generate ARK
+    identifiers.
+    """
+    for name, value in skos.ImportSkosData.options:
+        if name == 'cw-store':
+            value['choices'] = tuple(c for c in value['choices'] if c != 'rql')
+            assert 'nohook' in value['choices'], value['choices']
+            value['default'] = 'nohook'
+            break
+    else:
+        raise AssertionError(
+            'Could not find "cw-store" option in ImportSkosData ccplugin command')
+    del skos.ImportSkosData.cw_store_factories['rql']
+
+
+_skos_drop_rql_store()
+del _skos_drop_rql_store
+
+
 def _enc(string):
     if PY2 and not isinstance(string, str):
         string = string.encode('utf-8')



More information about the saem-devel mailing list