incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [1/2] git commit: [#7229] Handle errors in profile sections gracefully, and log
Date Mon, 03 Mar 2014 15:47:57 GMT
Repository: incubator-allura
Updated Branches:
  refs/heads/cj/7229 [created] adf92cf18


[#7229] Handle errors in profile sections gracefully, and log

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/d26d6e56
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d26d6e56
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d26d6e56

Branch: refs/heads/cj/7229
Commit: d26d6e56cfe8f06084e5d7277acfd2107db8d6a0
Parents: 44751e6
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Mon Mar 3 15:43:52 2014 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Mon Mar 3 15:46:07 2014 +0000

----------------------------------------------------------------------
 Allura/allura/ext/user_profile/user_main.py | 28 +++++++++++++++---------
 1 file changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d26d6e56/Allura/allura/ext/user_profile/user_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/user_profile/user_main.py b/Allura/allura/ext/user_profile/user_main.py
index 7065a32..9a9e5f1 100644
--- a/Allura/allura/ext/user_profile/user_main.py
+++ b/Allura/allura/ext/user_profile/user_main.py
@@ -29,6 +29,7 @@ from webob import exc
 from jinja2 import Markup
 from pytz import timezone
 from datetime import datetime
+from paste.deploy.converters import asbool
 
 from allura import version
 from allura.app import Application, SitemapEntry
@@ -258,16 +259,23 @@ class ProfileSectionBase(object):
         """
         if not self.check_display():
             return ''
-        tmpl = g.jinja2_env.get_template(self.template)
-        context = self.prepare_context({
-            'h': h,
-            'c': c,
-            'g': g,
-            'user': self.user,
-            'config': tg.config,
-            'auth': AuthenticationProvider.get(request),
-        })
-        return Markup(tmpl.render(context))
+        try:
+            tmpl = g.jinja2_env.get_template(self.template)
+            context = self.prepare_context({
+                'h': h,
+                'c': c,
+                'g': g,
+                'user': self.user,
+                'config': tg.config,
+                'auth': AuthenticationProvider.get(request),
+            })
+            return Markup(tmpl.render(context))
+        except Exception as e:
+            log.exception('Error rendering profile section %s: %s', type(self).__name__,
e)
+            if asbool(tg.config.get('debug')):
+                raise
+            else:
+                return ''
 
 
 class PersonalDataSection(ProfileSectionBase):


Mime
View raw message