selectors.py
changeset 6465 6401a9d0b5aa
parent 6457 3234d8d6e264
child 6565 e89de028d004
equal deleted inserted replaced
6464:11f9fbf6a645 6465:6401a9d0b5aa
  1428         if transition is not None and getattr(transition, 'name', None) in self.expected:
  1428         if transition is not None and getattr(transition, 'name', None) in self.expected:
  1429             return 1
  1429             return 1
  1430         return 0
  1430         return 0
  1431 
  1431 
  1432 
  1432 
       
  1433 class match_exception(ExpectedValueSelector):
       
  1434     """Return 1 if a view is specified an as its registry id is in one of the
       
  1435     expected view id given to the initializer.
       
  1436     """
       
  1437     def __init__(self, *expected):
       
  1438         assert expected, self
       
  1439         self.expected = expected
       
  1440 
       
  1441     @lltrace
       
  1442     def __call__(self, cls, req, exc=None, **kwargs):
       
  1443         if exc is not None and isinstance(exc, self.expected):
       
  1444             return 1
       
  1445         return 0
       
  1446 
       
  1447 
  1433 @objectify_selector
  1448 @objectify_selector
  1434 def debug_mode(cls, req, rset=None, **kwargs):
  1449 def debug_mode(cls, req, rset=None, **kwargs):
  1435     """Return 1 if running in debug mode."""
  1450     """Return 1 if running in debug mode."""
  1436     return req.vreg.config.debugmode and 1 or 0
  1451     return req.vreg.config.debugmode and 1 or 0
  1437 
  1452