Document PredicateMismatch for exception contexts #836

merged 1 commit into from Feb 10, 2013


None yet
2 participants

davidjb commented Jan 31, 2013

After recently attempting to add custom forbidden views to my application (Pyramid 1.4), I've found myself hitting PredicateMismatch exceptions. The following is a simplified example:

@forbidden_view_config([some predicates])
class ForbiddenView(object):

class MyView(object):
    def __call__(self):
        raise HTTPForbidden()

If a request comes for MyView, and that request fails to match the predicates specified for the ForbiddenView, a PredicateMismatch exception is raised. This exception isn't publicly documented, so I was unsure what this meant until I read the source code.

My suggestion is to document PredicateMismatch when it might occur (eg if predicates don't match for an exception context; eg at line 40 of pyramid/ when attempting to call an exception view) and what it means when you encounter one. I've done my best, but my documentation may need clarification.

I also think it would be useful to include a mention to PredicateMismatch somewhere more 'obvious' related to exception handling -- like

mcdonc added a commit that referenced this pull request Feb 10, 2013

Merge pull request #836 from davidjb/public-predicate-mismatch
Document PredicateMismatch for exception contexts

@mcdonc mcdonc merged commit 65cf215 into Pylons:master Feb 10, 2013


mcdonc commented Feb 10, 2013

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment