handle the fact that there might be no views registered in some configurations (#1382716) stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Tue, 04 Jan 2011 13:42:01 +0100
branchstable
changeset 6760 2c1fc68ac258
parent 6759 5d016d5bacca
child 6763 9c4820021f52
handle the fact that there might be no views registered in some configurations (#1382716)
hooks/notification.py
--- a/hooks/notification.py	Tue Jan 04 11:59:11 2011 +0100
+++ b/hooks/notification.py	Tue Jan 04 13:42:01 2011 +0100
@@ -22,6 +22,7 @@
 
 from logilab.common.textutils import normalize_text
 
+from cubicweb import RegistryNotFound
 from cubicweb.selectors import is_instance
 from cubicweb.server import hook
 from cubicweb.sobjects.supervising import SupervisionMailOp
@@ -42,8 +43,14 @@
     category = 'notification'
 
     def select_view(self, vid, rset, row=0, col=0):
-        return self._cw.vreg['views'].select_or_none(vid, self._cw, rset=rset,
-                                                     row=row, col=col)
+        try:
+            return self._cw.vreg['views'].select_or_none(vid, self._cw, rset=rset,
+                                                         row=row, col=col)
+        except RegistryNotFound: # can happen in some config
+                                 # (e.g. repo only config with no
+                                 # notification views registered by
+                                 # the instance's cubes)
+            return None
 
 
 class StatusChangeHook(NotificationHook):
@@ -69,7 +76,6 @@
             'comment': comment, 'previous_state': entity.previous_state.name,
             'current_state': entity.new_state.name})
 
-
 class RelationChangeHook(NotificationHook):
     __regid__ = 'notifyrelationchange'
     events = ('before_add_relation', 'after_add_relation',