jtushman/bouncer — pull request #9 by cbrand (2014-11-04 13:53:46+00:00)
Title: Added ability to set a custom subject match method for the rule subject  matcher

I needed this to include zope.interface matching to the rules engine.

But I think it is useful for other purposes too, to have a configuration directive for it. To register a custom matcher just use the "custom_subject_matcher" decorator:

```python
from bouncer.test_bouncer.models import Article
from bouncer import authorization_target, authorization_method, custom_subject_matcher

@custom_subject_matcher
def subject_match(rule, subject):
for subject in rule.subjects:
if subject == TestAuth.name:
return True
return False

@authorization_method
def authorize(user, they):
they.can(READ, 'Test')

article = Article()
sally = User(name='sally', admin=False)

assert sally.can(READ, article)
```