[PATCH seda v2] [pkg] Update usage of compound to its new API

Sylvain Thenault sylvain.thenault at logilab.fr
Wed Dec 13 09:55:31 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1513099186 -3600
#      Tue Dec 12 18:19:46 2017 +0100
# Node ID 4510e895498b9fc54e09e561a51ce5bb7fd93dc6
# Parent  451328134bee3f42ec84ed06f41202e114c5ef59
# Available At https://hg.logilab.org/review/cubes/seda
#              hg pull https://hg.logilab.org/review/cubes/seda -r 4510e895498b
[pkg] Update usage of compound to its new API

diff --git a/cubicweb_seda/views/clone.py b/cubicweb_seda/views/clone.py
--- a/cubicweb_seda/views/clone.py
+++ b/cubicweb_seda/views/clone.py
@@ -1,6 +1,6 @@
-# copyright 2015-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2015 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact at logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
 # the terms of the GNU Lesser General Public License as published by the Free
 # Software Foundation, either version 2.1 of the License, or (at your option)
@@ -18,11 +18,10 @@
 from cubicweb import uilib, _
 from cubicweb.predicates import is_instance, match_form_params, score_entity
 from cubicweb.web import Redirect, controller
 from cubicweb.web.views import uicfg
 
-from cubicweb_compound.entities import copy_entity
 from cubicweb_compound import views as compound
 from cubes.relationwidget import views as rwdg
 
 from .widgets import configure_relation_widget
 
@@ -65,12 +64,13 @@ class DoImportView(controller.Controller
         else:
             parent = ui_parent.first_level_choice.content_sequence
         clones = []
         for cloned_eid in self._cw.form['cloned'].split(','):
             original = self._cw.entity_from_eid(int(cloned_eid))
-            clones.append(copy_entity(original, seda_archive_unit=parent,
-                                      clone_of=original))
+            iclone = original.cw_adapt_to('IClonable')
+            clones.append(iclone.copy_entity(
+                original, seda_archive_unit=parent, clone_of=original))
         basemsg = (_('{0} has been imported') if len(clones) == 1 else
                    _('{0} have been imported'))
         msg = self._cw._(basemsg).format(u', '.join(clone.dc_title() for clone in clones))
         raise Redirect(ui_parent.absolute_url(__message=msg))
 
diff --git a/dev-requirements.txt b/dev-requirements.txt
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -1,1 +1,2 @@
 pytest
+http://hg.logilab.org/review/cubes/compound/archive/tip.tar.bz2#egg=cubicweb-compound
diff --git a/test/test_hooks.py b/test/test_hooks.py
--- a/test/test_hooks.py
+++ b/test/test_hooks.py
@@ -18,11 +18,10 @@
 from os.path import dirname, join
 from itertools import chain, repeat
 
 from cubicweb.devtools.testlib import CubicWebTC
 
-from cubicweb_compound.entities import copy_entity
 from cubicweb_seda import testutils, dataimport
 
 
 class ValidationHooksTC(CubicWebTC):
 
@@ -266,11 +265,12 @@ class DispatchFileCategoryTC(CubicWebTC)
 
             bdo_comp.cw_set(file_category=self.categories['document'])
             cnx.commit()
             self.assertFormatEqual(bdo_comp, [], [])
             # until it's imported into some parent
-            copy_entity(unit_comp, seda_archive_unit=unit_alt_seq, clone_of=unit_comp)
+            iclone = unit_comp.cw_adapt_to('IClonable')
+            iclone.copy_entity(unit_comp, seda_archive_unit=unit_alt_seq, clone_of=unit_comp)
             cnx.commit()
             imported_bdo, = [x for x in transfer.binary_data_objects if x.eid != bdo.eid]
             self.assertFormatEqual(imported_bdo,
                                    ['application/msword', 'application/pdf'],
                                    ['fmt/37', 'fmt/38', 'fmt/14'])


More information about the saem-devel mailing list