[snapshot/master] add config option to suppress Python warnings in production
---
web/app/development.ini | 1 +
web/app/snapshot/config/deployment.ini_tmpl | 1 +
web/app/snapshot/config/middleware.py | 6 ++++++
web/app/test.ini | 1 +
4 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/web/app/development.ini b/web/app/development.ini
index 6e21f0e..716509c 100644
--- a/web/app/development.ini
+++ b/web/app/development.ini
@@ -5,6 +5,7 @@
#
[DEFAULT]
debug = true
+warnings = true
# Uncomment and replace with the address which should receive any error reports
#email_to = you@yourdomain.com
smtp_server = localhost
diff --git a/web/app/snapshot/config/deployment.ini_tmpl b/web/app/snapshot/config/deployment.ini_tmpl
index f8aac3a..55ff605 100644
--- a/web/app/snapshot/config/deployment.ini_tmpl
+++ b/web/app/snapshot/config/deployment.ini_tmpl
@@ -5,6 +5,7 @@
#
[DEFAULT]
debug = false
+warnings = false
email_to = @@EMAIL_TO@@
smtp_server = localhost
error_email_from = @@EMAIL_FROM@@
diff --git a/web/app/snapshot/config/middleware.py b/web/app/snapshot/config/middleware.py
index 40493e0..b845f07 100644
--- a/web/app/snapshot/config/middleware.py
+++ b/web/app/snapshot/config/middleware.py
@@ -1,4 +1,6 @@
"""Pylons middleware initialization"""
+import warnings
+
from beaker.middleware import CacheMiddleware, SessionMiddleware
from paste.cascade import Cascade
from paste.registry import RegistryManager
@@ -58,6 +60,10 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
else:
app = StatusCodeRedirect(app, [400, 401, 403, 404, 500])
+ # Optionally suppress all Python warnings
+ if not asbool(config['warnings']):
+ warnings.simplefilter("ignore")
+
# Establish the Registry for this application
app = RegistryManager(app)
diff --git a/web/app/test.ini b/web/app/test.ini
index cb54568..5ea8514 100644
--- a/web/app/test.ini
+++ b/web/app/test.ini
@@ -5,6 +5,7 @@
#
[DEFAULT]
debug = true
+warnings = true
# Uncomment and replace with the address which should receive any error reports
#email_to = you@yourdomain.com
smtp_server = localhost
--
1.5.6.5
Reply to: