Commits

Scott Torborg  committed 3db8b34

update paginate so that it checks for sqlalchemy >= 0.4 instead of == 0.4 or 0.5

  • Participants
  • Parent commits 3032f5d

Comments (0)

Files changed (1)

File webhelpers/paginate.py

 except:
     sqlalchemy_available = False
 else:
-    sqlalchemy_available = sqlalchemy.__version__
+    from pkg_resources import parse_version
+    sqlalchemy_available = (parse_version(sqlalchemy.__version__) >=
+                            parse_version('0.4'))
 
 def get_wrapper(obj, sqlalchemy_session=None):
     """
     if isinstance(obj, (list, tuple)):
         return obj
     # Is SQLAlchemy 0.4 available? (0.3 is not supported - sorry)
-    if sqlalchemy_available.startswith('0.4') or sqlalchemy_available.startswith('0.5'):
+    if sqlalchemy_available:
         # Is the collection a query?
         if isinstance(obj, sqlalchemy.orm.query.Query):
             return _SQLAlchemyQuery(obj)