'If type_ is a subclass of self.exc and value has attributes matching
self.attrs, raise ResourceDenied.  Otherwise let the exception
propagate (if any).'

def __exit__(self, type_=None, value=None, traceback=None):

    if ((type_ is not None) and issubclass(self.exc, type_)):
        for (attr, attr_value) in self.attrs.iteritems():
            if (not hasattr(value, attr)):
                break
            if (getattr(value, attr) != attr_value):
                break
        else:
            raise ResourceDenied('an    optional    resource    is    not    available')
