Vladimir Mihailenco avatar Vladimir Mihailenco committed 81dc904

Add Python 2.5 (GAE) compatibility

Comments (0)

Files changed (1)

flaskext/principal.py

 
 """
 
+from __future__ import with_statement
+
 import sys
 from functools import partial, wraps
-from collections import namedtuple, deque
+from collections import deque
+try:
+    from collections import namedtuple
+except ImportError:
+    from namedtuple import namedtuple
 
 
 from flask import g, session, current_app, abort
         """Does the same thing as ``self.union(other)``
         """
         return self.union(other)
-    
+
     def __or__(self, other):
         """Does the same thing as ``self.difference(other)``
         """
 
         If ``http_exception`` is passed then ``abort()`` will be called
         with the HTTP exception code. Otherwise a ``PermissionDenied``
-        exception will be raised if the identity does not meet the 
+        exception will be raised if the identity does not meet the
         requirements.
 
         :param http_exception: the HTTP exception code (403, 401 etc)
 
     def test(self, http_exception=None):
         """
-        Checks if permission available and raises relevant exception 
+        Checks if permission available and raises relevant exception
         if not. This is useful if you just want to check permission
         without wrapping everything in a require() block.
 
 
         with self.require(http_exception):
             pass
-        
+
     def reverse(self):
         """
-        Returns reverse of current state (needs->excludes, excludes->needs) 
+        Returns reverse of current state (needs->excludes, excludes->needs)
         """
 
         p = Permission()
         return p
 
     def difference(self, other):
-        """Create a new permission consisting of requirements in this 
+        """Create a new permission consisting of requirements in this
         permission and not in the other.
         """
 
             return False
 
         return True
-       
+
     def can(self):
         """Whether the required context for this permission has access
 
             if identity is not None:
                 self.set_identity(identity)
                 return
-
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.