You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/05/09 23:42:28 UTC

[08/18] git commit: [#7257] ticket:562 Made extension log exceptions and fail silently

[#7257] ticket:562 Made extension log exceptions and fail silently


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

Branch: refs/heads/db/7257
Commit: bda37b78001cf0e6d329e2cde0e3ff305898dc5e
Parents: f2cdeed
Author: Ferens Dmitriy <fe...@gmail.com>
Authored: Thu Apr 3 12:49:06 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri May 9 18:56:47 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/session.py | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/bda37b78/Allura/allura/model/session.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/session.py b/Allura/allura/model/session.py
index b2abf3b..2d60afa 100644
--- a/Allura/allura/model/session.py
+++ b/Allura/allura/model/session.py
@@ -67,26 +67,31 @@ class IndexerSessionExtension(ManagedSessionExtension):
             result[class_path].append(obj)
         return result
 
-    def _add_to_index(self, tasks, obj_list):
-        task = tasks.get('add')
-        if task: task.post([o._id for o in obj_list])
+    def _index_action(self, tasks, obj_list, action):
+        task = tasks.get(action)
+        if task:
+            if action == 'add':
+                args = ([o._id for o in obj_list],)
+            else:
+                args = ([o.index_id() for o in obj_list],)
+
+            try:
+                task.post(*args)
+            except:
+                log.error('Error calling %s', task.__name__)
 
-    def _del_from_index(self, tasks, obj_list):
-        task = tasks.get('del')
-        if task: task.post([o.index_id() for o in obj_list])
 
     def after_flush(self, obj=None):
         actions = [
-            ((self.objects_added + self.objects_modified), self._add_to_index),
-            ((self.objects_deleted), self._del_from_index)
+            ((self.objects_added + self.objects_modified), 'add'),
+            ((self.objects_deleted), 'del')
         ]
         for obj_list, action in actions:
             if obj_list:
                 types_objects_map = self._objects_by_types(obj_list)
                 for class_path, obj_list in types_objects_map.iteritems():
                     tasks = self.TASKS.get(class_path, {})
-                    action(tasks, obj_list)
-                        
+                    self._index_action(tasks, obj_list, action)
 
 
 class ArtifactSessionExtension(ManagedSessionExtension):