allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [08/20] git commit: [#7257] ticket:562 Made extension log exceptions and fail silently
Date Wed, 21 May 2014 14:44:56 GMT
[#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/0df1dea7
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/0df1dea7
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/0df1dea7

Branch: refs/heads/master
Commit: 0df1dea7e953cb1eebf61cce6008306acb3729a1
Parents: e674b0b
Author: Ferens Dmitriy <ferensdima@gmail.com>
Authored: Thu Apr 3 12:49:06 2014 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed May 21 14:44:20 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/0df1dea7/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):


Mime
View raw message