do not crash if preview is not available at all
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 06 Oct 2010 16:42:05 +0200
changeset 241 d785490eafb8
parent 240 6a74a6011af7
child 242 d62135e85bb9
do not crash if preview is not available at all
views/__init__.py
--- a/views/__init__.py	Tue Oct 05 18:18:49 2010 +0200
+++ b/views/__init__.py	Wed Oct 06 16:42:05 2010 +0200
@@ -3,8 +3,6 @@
 from cubicweb.web.views import ibreadcrumbs
 from cubicweb.web.views.autoform import AutomaticEntityForm
 
-from cubes.preview.views.forms import PreviewFormMixin
-
 class BlogEntryIBreadCrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter):
     __select__ = is_instance('BlogEntry', 'MicroBlogEntry')
     def parent_entity(self):
@@ -38,13 +36,14 @@
             return rset.get_entity(0,0)
 
 
-class PreviewAutomaticEntityForm(PreviewFormMixin, AutomaticEntityForm):
-    preview_mode = 'inline'
-    __select__ = AutomaticEntityForm.__select__ & is_instance('Blog', 'BlogEntry',
-                                                              'MicroBlog', 'MicroBlogEntry')
-
 def registration_callback(vreg):
     vreg.register(BlogEntryIBreadCrumbsAdapter)
     vreg.register(BlogEntryIPrevNextAdapter)
     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('Blog', 'BlogEntry',
+                                                                      'MicroBlog', 'MicroBlogEntry')
         vreg.register(PreviewAutomaticEntityForm)