app/soc/views/helper/access.py
changeset 1486 c417a4188e73
parent 1481 0ccf92d073e8
child 1488 4b7cec48e26c
--- a/app/soc/views/helper/access.py	Tue Feb 24 19:49:27 2009 +0000
+++ b/app/soc/views/helper/access.py	Tue Feb 24 19:51:40 2009 +0000
@@ -426,6 +426,29 @@
     if not self.hasMembership(roles, django_args):
       raise out_of_band.AccessViolation(message_fmt)
 
+  def checkHasAny(self, django_args, checks):
+    """Checks if any of the checks passes.
+
+    If none of the specified checks passes, the exception that the first of the
+    checks raised is reraised.
+    """
+
+    first = None
+
+    for checker_name, args in checks:
+      try:
+        self.doCheck(checker_name, django_args, args)
+        break
+      except out_of_band.Error, e:
+        # store the first esception
+        first = first if first else e
+    else:
+      # one check passed, all is well
+      return
+
+    # none passed, re-raise the first exception
+    raise first
+
   def allow(self, django_args):
     """Never raises an alternate HTTP response.  (an access no-op, basically).