Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1588 (closed enhancement: fixed)

Opened 12 years ago

Last modified 10 years ago

paginate for non-select result objects

Reported by: cck197 Owned by: Chris Arndt
Priority: normal Milestone: 1.x
Component: TurboGears Version: 1.0.3
Severity: normal Keywords:


I'm building a web front end for a system where the model is defined by a server I communicate with via SOAP and soaplib. Most of the data I need to display are flat lists of objects returned by a remote procedure call. The paginate decorator is working well for this except that column sorting doesn't work.

I fixed my problem by applying the following patch, essentially it uses the sort method build into list objects and promotes the check for non-select results objects to the first made (as I do have SQLAlchemy and SQLObject installed). Is this something you would be interested in incorporating, or is there a better way to achieve sorting simple lists?


paginate.py.diff Download (1.6 KB) - added by cck197 12 years ago.
Patch for turbogears/turbogears/paginate.py

Change History

Changed 12 years ago by cck197

Patch for turbogears/turbogears/paginate.py

comment:1 Changed 11 years ago by VZ

FWIW here is a trivial diff to solve the same problem with version 1.0 (which is the latest available in Debian right now which is why I use it):

/usr/share/python-support/python-turbogears/turbogears/paginate.py  2008-01-11 20:16:16.000000000 +0100
+++ /tmp/paginate.py    2008-01-11 20:16:10.000000000 +0100
@@ -54,6 +54,10 @@
                         var_data = var_data.reversed()
             elif isinstance(var_data, list):
                 row_count = len(var_data)
+                if default_order:
+                    var_data.sort(key=lambda item: getattr(item, order))
+                if reversed:
+                    var_data.reverse()
                 raise 'Variable is not a list or SelectResults'

Maybe it ca be useful to somebody.

comment:2 Changed 11 years ago by Chris Arndt

  • Owner changed from anonymous to roger
  • Milestone set to __unclassified__

Roger, since you have been working on paginate the most recently, could you check if this ticket is still valid and useful or if it has been obsoleted by changes in the paginate decorator in the meantime?

If the latter feel free to close this as "wontfix" or "fixed" as appropriate. If you don't have the time to take care of this, please assign back to me.

comment:3 Changed 11 years ago by Chris Arndt

  • Owner changed from roger to roger.demetrescu

comment:4 Changed 10 years ago by jorge.vargas

  • Owner changed from roger.demetrescu to Chris Arndt
  • Milestone changed from __unclassified__ to 1.x

comment:5 Changed 10 years ago by chrisz

  • Status changed from new to closed
  • Resolution set to fixed

Should have been solved more thoroughly in r4347. The attached patch will no more be applicable anyway because of these changes. If anything still needs improvement, please reopen.

Note: See TracTickets for help on using tickets.