# HG changeset patch # User mgood # Date 1151974361 0 # Node ID fc685d0c93420722e352a0acd71b818aa0d56d76 # Parent 436e30c8420b27f4703e245464923c1de57c18f7 define `__contains__` for using the `in` operator w/ the permission cache diff --git a/examples/trac/trac/perm.py b/examples/trac/trac/perm.py --- a/examples/trac/trac/perm.py +++ b/examples/trac/trac/perm.py @@ -268,6 +268,7 @@ def has_permission(self, action): return self.perms.has_key(action) + __contains__ = has_permission def assert_permission(self, action): if not self.perms.has_key(action): @@ -282,6 +283,7 @@ def has_permission(self, action): return False + __contains__ = has_permission def assert_permission(self, action): raise PermissionError(action)