incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [25/25] git commit: [#4942] Gracefully handle bad / missing tools
Date Mon, 29 Oct 2012 20:10:47 GMT
[#4942] Gracefully handle bad / missing tools

Forward-ported from https://sourceforge.net/p/allura/git/merge-requests/9/

Signed-off-by: Cory Johns <johnsca@geek.net>


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

Branch: refs/heads/cj/5076
Commit: d90e6dc3cda217ab68b7ba8317271603a4f1fce9
Parents: cf03d39
Author: Cory Johns <johnsca@geek.net>
Authored: Fri Oct 26 19:32:14 2012 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Fri Oct 26 19:42:11 2012 +0000

----------------------------------------------------------------------
 Allura/allura/model/project.py |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d90e6dc3/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 9580b25..5938be1 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -404,7 +404,13 @@ class Project(MappedClass, ActivityNode, ActivityObject):
         for ac in self.app_configs:
             if excluded_tools and ac.tool_name in excluded_tools:
                 continue
-            App = ac.load()
+            # Tool could've been uninstalled in the meantime
+            try:
+                App = ac.load()
+            # If so, we don't want it listed
+            except KeyError as e:
+                log.exception('AppConfig %s references invalid tool %s', ac._id, ac.tool_name)
+                continue
             app = App(self, ac)
             if app.is_visible_to(c.user):
                 for sm in app.main_menu():
@@ -533,8 +539,8 @@ class Project(MappedClass, ActivityNode, ActivityObject):
         for sub in self.direct_subprojects:
             result.append({'ordinal':int(sub.ordinal), 'sub':sub, 'rank':1})
         for ac in self.app_configs:
-            App = g.entry_points['tool'][ac.tool_name]
-            if include_hidden or not App.hidden:
+            App = g.entry_points['tool'].get(ac.tool_name)
+            if include_hidden or App and not App.hidden:
                 ordinal = ac.options.get('ordinal', 0)
                 rank = 0 if ac.options.get('mount_point', None) == 'home' else 1
                 result.append({'ordinal':int(ordinal), 'ac':ac, 'rank':rank})


Mime
View raw message