Anonymous avatar Anonymous committed 700c1df

denies > excludes

Comments (0)

Files changed (2)

flaskext/principal.py

     """
     def __init__(self, *needs):
         self.needs = set(needs)
-        self.denies = set()
+        self.excludes = set()
         """A set of needs, any of which must be present in an identity to have
         access.
         """
         
     def negate(self):
         """
-        Returns negative of current state (needs->denies, denies->needs) 
+        Returns negative of current state (needs->excludes, excludes->needs) 
         """
 
         p = Permission()
-        p.needs.update(self.denies)
-        p.denies.update(self.needs)
+        p.needs.update(self.excludes)
+        p.excludes.update(self.needs)
         return p
 
     def union(self, other):
         :param other: The other permission
         """
         p = Permission(*self.needs.union(other.needs))
-        p.denies.update(self.denies)
-        p.denies.update(other.denies)
+        p.excludes.update(self.excludes)
+        p.excludes.update(other.excludes)
         return p
 
     def issubset(self, other):
         :param other: The other permission
         """
         return self.needs.issubset(other.needs) and \
-               self.denies.issubset(other.denies)
+               self.excludes.issubset(other.excludes)
 
     def allows(self, identity):
         """Whether the identity can access this permission.
         if self.needs and not self.needs.intersection(identity.provides):
             return False
 
-        if self.denies and self.denies.intersection(identity.provides):
+        if self.excludes and self.excludes.intersection(identity.provides):
             return False
 
         return True
 
 class Denial(Permission):
     """
-    Shortcut class for passing denied needs.
+    Shortcut class for passing excluded needs.
     """
 
-    def __init__(self, *denies):
-        self.denies = set(denies)
+    def __init__(self, *excludes):
+        self.excludes = set(excludes)
         self.needs = set()
 
 

tests/test_principal.py

 
     p = Permission(('a', 'b'))
     d = p.negate()
-    print d.denies
-    assert ('a', 'b') in d.denies
+    print d.excludes
+    assert ('a', 'b') in d.excludes
 
 def test_identity_changed():
     client = mkapp().test_client()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.