# HG changeset patch
# User Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
# Date 1475514445 -7200
#      Mon Oct 03 19:07:25 2016 +0200
# Node ID 7eebe9f503ee5c9e9f9bfbfab9882650ec6b0b89
# Parent  375fb06cb9b717f27bf77e23c66e8449f8a3ff40
safety belt, do not call create_index is no connection is available

diff --git a/entities.py b/entities.py
--- a/entities.py
+++ b/entities.py
@@ -72,7 +72,9 @@
             settings = {}
             deep_update(settings, self.settings)
             deep_update(settings, custom_settings)
-        es.create_index(es.get_connection(self._cw.vreg.config), index_name, settings)
+        es_cnx = es.get_connection(self._cw.vreg.config)
+        if es_cnx is not None:
+            es.create_index(es_cnx, index_name, settings)
 
 
 class IFullTextIndexSerializable(view.EntityAdapter):