Make debug mode usable without pyramid_debugtoolbar
authorDenis Laxalde <denis.laxalde@logilab.fr>
Wed, 29 Apr 2015 11:39:35 +0200
changeset 11563 f9473eb6a8a9
parent 11562 a49f08423f02
child 11564 a6547ff97ce0
Make debug mode usable without pyramid_debugtoolbar Add the latter in Debian recommends along the way. Closes #5310434.
debian/control
pyramid_cubicweb/__init__.py
--- a/debian/control	Thu Feb 26 00:56:32 2015 +0100
+++ b/debian/control	Wed Apr 29 11:39:35 2015 +0200
@@ -22,6 +22,8 @@
  python-waitress (>= 0.8.9),
  cubicweb-common (>= 3.19.3),
 # XXX wsgicors?
+Recommends:
+ python-pyramid_debugtoolbar
 Description: Integrate CubicWeb with a Pyramid application
  Provides pyramid extensions to load a CubicWeb instance and serve it through
  the pyramid stack.
--- a/pyramid_cubicweb/__init__.py	Thu Feb 26 00:56:32 2015 +0100
+++ b/pyramid_cubicweb/__init__.py	Wed Apr 29 11:39:35 2015 +0200
@@ -1,4 +1,5 @@
 import os
+from warnings import warn
 import wsgicors
 
 from cubicweb.cwconfig import CubicWebConfiguration as cwcfg
@@ -43,7 +44,11 @@
 
     config = Configurator(settings=settings)
     if cwconfig.debugmode:
-        config.include('pyramid_debugtoolbar')
+        try:
+            config.include('pyramid_debugtoolbar')
+        except ImportError:
+            warn('pyramid_debugtoolbar package not available, install it to '
+                 'get UI debug features', RuntimeWarning)
     config.registry['cubicweb.config'] = cwconfig
     config.registry['cubicweb.repository'] = repo = cwconfig.repository()
     config.registry['cubicweb.registry'] = repo.vreg