I've just been examining the code for the paginate decorator to see whether it can handle more than just result sets and lists and was slightly concerned to see that it does an isinstance(vardata,list) rather than hasattr(vardata,'__len__') before calling len(vardata) to get the number of items in the data being paginated. The code in question being:
194-197 of http://trac.turbogears.org/browser/branches/1.0/turbogears/paginate.py Now I presume this means that if I was to create an object that implements __len__ and supports slicing that it won't work with the paginate decorator? Or am I missing something? I'd like to be able to create a custom "query" object so I can "fix" this page: http://chrss.co.uk/games/ Which shows a list of games and includes the number of moves in each game. It's only broken in so far as at the moment I am performing one query per game to get the number of moves. (I'm using SQLObject) Ideally I'd like to be able to use some of the stuff I've played around with here: http://psychicorigami.com/2007/12/16/using-raw-sql-with-sqlobject-and-keeping-the-object-y-goodness/ To reduce that down to one query, whilst still using the paginate decorator. So can I use "list-like" objects with the paginate decorator? If not would it be worth me submitting a patch for this? cheers, John --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---