Anonymous avatar Anonymous committed a618b67

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

Comments (0)

Files changed (1)

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:
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.