Commits

Benoit Chesneau  committed a618b67

since we always need revisions in right order, sort them every time we get them.

  • Participants
  • Parent commits af88a7d
  • Tags refactored

Comments (0)

Files changed (1)

File friendpaste/models.py

     
     def get_revisions(cls, db, snippetid):
         results = cls.view(db, '_view/paste/by_id', startkey=[str(snippetid)], endkey=[str(snippetid),10])
-        return list(iter(results))
+        revisions = list(iter(results))
+        if revisions:
+            revisions.sort(lambda a,b: cmp(a.updated, b.updated))
+            revisions.reverse()
+        return revisions
     get_revisions = classmethod(get_revisions)
         
     def get_changeset(cls, db, snippetid, rev=None):
         if not all_revisions:
             raise ResourceNotFound
             
-        all_revisions.sort(lambda a,b: cmp(a.updated, b.updated))
-        all_revisions.reverse()
         snippet = all_revisions[0]
-        
         if snippet.revid == rev:
             diff_to = snippet.snippet
             after = True
         all_revisions = cls.get_revisions(db, snippetid)
         if not all_revisions:
             raise ResourceNotFound
-            
-        all_revisions.sort(lambda a,b: cmp(a.updated, b.updated))
-        all_revisions.reverse()
         
         i = 0
         if rev is not None: