Oleksandr Moskalenko schrieb:
> * Diez B. Roggisch <[EMAIL PROTECTED]> [2008-11-03 21:50:06 +0100]:
> 
>> Oleksandr Moskalenko schrieb:
>>> * Diez B. Roggisch <[EMAIL PROTECTED]> [2008-11-03 21:03:15 +0100]:
>>>
>>> Here is my currently working controller/template pair without pagination 
>>> with
>>> all data in one big table with sortable columns:
>>>
>>> Controller:
>>>
>>>     @expose('chemcupboard.templates.listall')
>>>     def listall(self, sort="id"):
>>>         invquery = DBSession.query(t_inventory).order_by(sort)
>>>         return dict(title='CCM - Chemical Inventory', organization = 'John 
>>> Doe Lab', iquery = invquery, sort = None)
>>> Template:
>>>
>>>         <table>
>>>             <tr class="heading">
>>>                 ${h.th_sortable(sort, "id", "ID", "?sort=id")}
>>>                 ${h.th_sortable(sort, "name", "Chemical Name", 
>>> "?sort=name")}
>>>                 ${h.th_sortable(sort, "location", "General Location", 
>>> "?sort=location")}
>>>                 ${h.th_sortable(sort, "sub_location", "Sub Location", 
>>> "?sort=sub_location")}
>>>             </tr>
>>>             <tr py:for="ilist in iquery">
>>>                 <td>${ilist.id}</td>
>>>                 <td>${ilist.name}</td>
>>>                 <td>${ilist.location}</td>
>>>                 <td>${ilist.sub_location}</td>
>>>             </tr>
>>>         </table>
>>>
>>> Attempt to add pagination:
>>>
>>> Controller:
>>>
>>>     @expose('chemcupboard.templates.list')
>>>     @paginate('invquery', items_per_page=30, use_prefix=False)
>>>     def list(self, sort="id"):
>>>         invquery = DBSession.query(t_inventory).order_by(sort)
>>>         return dict(title='CCM - Chemical Inventory', organization = 'John 
>>> Doe Lab', iquery = invquery, sort = None)
>>>
>>> Template:
>>>
>>>     <div id="pagearea">
>>>         <p>
>>>         ${c.paginators.iquery.pager()}
>> **invquery** or **iquery**?
>>
>> You need to spell things proper of course.
>>
>> Diez
> 
> Diez,
> 
> I did write that if I use @paginate('iquery', ...) then I get the
> "InvalidRequestError: This operation requires a Query against a single 
> mapper."
> traceback. So, no this is not a misspelling as far as I can tell. Do you have
> any other suggestions?

No, because it is the proper one. The paginate decorator can't work if 
you don't return a collection-like object under the same name you 
declare it to page. How do you expect it to work otherwise - by fuzzy 
name matching?

I don't know where you wrote that InvalidRequestError (I don't see that 
in the mail thread here), and I don't have the slightes clue why 
renaming should change anything about it.

But if you just for an experiment return a long list instead a 
query-object and just display that, you will see that the paginate 
decorator works just fine.

Then solve your query-problem - and things should work.

Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to