Anonymous avatar Anonymous committed fb9ac97

fixed bool

Comments (0)

Files changed (2)


-    def __bool__(self):
-        return self.can()
+    def __nonzero__(self):
+        return bool(self.can())
     def require(self, http_exception=None):
         """Create a principal for this permission.
         The principal may be used as a context manager, or a decroator.
+        If ``http_exception`` is passed then ``abort()`` will be called
+        with the HTTP exception code. Otherwise a ``PermissionDenied``
+        exception will be raised.
+        :param http_exception: the HTTP exception code (403, 401 etc)
         return IdentityContext(self, http_exception)


     def k():
         return Response('hello')
+    @app.route('/l')
+    def l():
+        s = []
+        if not admin_or_editor:
+            s.append("not admin")
+        i = Identity('ali')
+        identity_changed.send(app, identity=i)
+        if admin_or_editor:
+            s.append("now admin")  
+        return Response('\n'.join(s))
     return app
 def mkadmin():
     response ="/k")
     assert response.status_code == 200
+def test_permission_bool():
+    client = mkapp().test_client()
+    response ='/l')
+    print
+    assert response.status_code == 200
+    assert 'not admin' in
+    assert 'now admin' in
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
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.