# HG changeset patch
# User Aurelien Campeas <aurelien.campeas@logilab.fr>
# Date 1286376139 -7200
#      Wed Oct 06 16:42:19 2010 +0200
# Node ID eebe8dab2cc2eb1af9e83d4102e9dcf646e6c19e
# Parent  b6d7fd422692be4cff0b072a33c6cf369b95559e
do not crash if preview is not available at all

diff --git a/views.py b/views.py
--- a/views.py
+++ b/views.py
@@ -14,8 +14,6 @@
 from cubicweb.web.views import primary
 from cubicweb.web.views.autoform import AutomaticEntityForm
 
-from cubes.preview.views.forms import PreviewFormMixin
-
 uicfg.primaryview_section.tag_attribute(('Card', 'title'), 'hidden')
 uicfg.primaryview_section.tag_attribute(('Card', 'synopsis'), 'hidden')
 uicfg.primaryview_section.tag_attribute(('Card', 'wikiid'), 'hidden')
@@ -43,13 +41,16 @@
     def content_navigation_components(self, context):
         pass
 
-class PreviewAutomaticEntityForm(PreviewFormMixin, AutomaticEntityForm):
-    preview_mode = 'inline'
-    __select__ = AutomaticEntityForm.__select__ & is_instance('Card')
 
 def registration_callback(vreg):
     vreg.register(CardPrimaryView)
     vreg.register(CardInlinedView)
     if 'preview' in vreg.config.cubes():
+
+        from cubes.preview.views.forms import PreviewFormMixin
+        class PreviewAutomaticEntityForm(PreviewFormMixin, AutomaticEntityForm):
+            preview_mode = 'inline'
+            __select__ = AutomaticEntityForm.__select__ & is_instance('Card')
+
         vreg.register(PreviewAutomaticEntityForm)