[sobjects] Return early in SyncCKANDataset if entity is not ICKANDataset adaptable draft default tip
authorDenis Laxalde <denis.laxalde@logilab.fr>
Thu, 18 May 2017 16:01:24 +0200
changeset 77 6205766e56fa
parent 76 db3ad7822146
[sobjects] Return early in SyncCKANDataset if entity is not ICKANDataset adaptable
sobjects.py
--- a/sobjects.py	Mon Jan 26 14:25:12 2015 +0100
+++ b/sobjects.py	Thu May 18 16:01:24 2017 +0200
@@ -87,7 +87,12 @@
         """Create or update a CKAN dataset using dataset-like entity eid"""
         entity = self._cw.entity_from_eid(eid)
         datasetid = entity.ckan_dataset_id
-        data = entity.cw_adapt_to('ICKANDataset').ckan_data()
+        adapter = entity.cw_adapt_to('ICKANDataset')
+        if adapter is None:
+            self.debug('not synching %s (not ICKANDataset adaptable)',
+                       entity)
+            return
+        data = adapter.ckan_data()
         config = self._cw.vreg.config
         if datasetid is not None:
             update_dataset(config, eid, datasetid, data)