Ticket #1588 (new enhancement)

Opened 11 months ago

Last modified 13 hours ago

paginate for non-select result objects

Reported by: cck197 Assigned to: roger.demetrescu
Priority: normal Milestone: __unclassified__
Component: TurboGears Version: 1.0.3
Severity: normal Keywords:
Cc:

Description

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?

Attachments

paginate.py.diff (1.6 kB) - added by cck197 on 10/14/07 17:29:08.
Patch for turbogears/turbogears/paginate.py

Change History

10/14/07 17:29:08 changed by cck197

  • attachment paginate.py.diff added.

Patch for turbogears/turbogears/paginate.py

01/11/08 13:19:11 changed 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()
             else:
                 raise 'Variable is not a list or SelectResults'

Maybe it ca be useful to somebody.

08/28/08 15:52:57 changed 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.

08/28/08 15:53:39 changed by Chris Arndt

  • owner changed from roger to roger.demetrescu.