Дайте контроллер и метод, подобный:
import genshi
from pylons import tmpl_context, request, url
import re
from tg import expose, flash
from tg.controllers import redirect
from tg.decorators import validate
import tw.forms as twf
from tw.forms.datagrid import DataGrid
from tg.decorators import paginate
from tg.i18n import ugettext as _
from repoze.what.predicates import has_permission
from interlock.lib.base import BaseController
assigned_seller_product_grid = DataGrid(fields=[
('Product Name', 'name'),
('Producer', 'producer'),
])
unassigned_seller_product_grid = DataGrid(fields=[
('Product Name', 'name'),
('Producer', 'producer'),
])
class SellerController(BaseController):
allow_only = has_permission('manage')
@paginate("unassigned", items_per_page=5, use_prefix=True)
@paginate("assigned", items_per_page=5, use_prefix=True)
@expose('demo.templates.sellers.products')
def products(self, uid = None, **kw):
seller = uid is not None and DBSession.query(SellerModel).filter_by(uid=uid, deleted=False).first()
if uid is not None and not seller:
flash(_('No Seller ID Defined'), 'warning')
redirect('/seller/')
unassigned = DBSession.query(ProductModel).filter(~ProductModel.sellers.any(SellerModel.uid == seller.uid)).filter(ProductModel.deleted == False)
assigned = DBSession.query(ProductModel).filter(ProductModel.sellers.any(SellerModel.uid == seller.uid)).filter(ProductModel.deleted == False)
return dict(seller=seller,
assigned=assigned,
unassigned = unassigned,
assigned_grid=assigned_seller_product_grid,
unassigned_grid=unassigned_seller_product_grid,
page='seller')
И шаблон, подобный:
<h1>Assigned Products</h1>
<div py:if="assigned">${assigned_grid(assigned)}</div>
<div>${tmpl_context.paginators.assigned.pager(page_param='assigned_page')}</div>
<h1>Unassigned Products</h1>
<div py:if="unassigned">${unassigned_grid(unassigned)}</div>
<div>${tmpl_context.paginators.unassigned.pager(page_param='unassigned_page')}</div>
Я вижу, что TG2 правильно генерирует ссылки пагинации, но нумерация страниц просто меняет страницу простоиспользуя первый декоратор, игнорируя второй.Кто-нибудь сталкивался с этой проблемой раньше?
Спасибо.