Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 406291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:28:55+00:00 2026-05-12T17:28:55+00:00

I look an example of paginating from http://rapidprototype.ch/bg2docs/tg2pagination.html for my Turbogears 2 project and

  • 0

I look an example of paginating from http://rapidprototype.ch/bg2docs/tg2pagination.html for my Turbogears 2 project and it works great but, I have a problem regarding my query parameters when I change the page I’m looking.

This is what I have in my controller when listing.

def list(self, page=1, **kw):
    q = ""

    if kw.has_key('q'):
        log.debug("searching %s" % kw)
        q = kw['q']

    if kw.has_key('all'):
        q = ""

    products = DBSession.query(model.Product).filter(
        or_(model.Product.name.like('%%%s%%' % q),
            model.Product.description.like('%%%s%%' % q),
            model.Product.model.like('%%%s%%' % q),
            model.Product.code.like('%%%s%%' % q))).all()

    def get_link(product):
        return Markup("""<a href="form?id=%s">%s</a>""" % (product.id, product.id))

    product_fields = [
        (Markup("""<a href="?s=id">Id</a>"""), get_link),
        (u'Name', 'name'),
        (u'Model', 'model'),
        (u'Code', 'code'),
        (u'Description', 'description')]

    product_grid = MyDataGrid(fields = product_fields)

    currentPage = paginate.Page(products, page, items_per_page=50)

    return dict(currentPage=currentPage, 
        title=u'Products List', item=u'product', items=u'products',
        data=currentPage.items, 
        grid=product_grid,
        page=u'Search %s results' % q,
        q=q,
        hits=len(products))

This is the html template fragment

<h1>List of ${items}</h1>
<form action="list" method="get">
   <input name="q" type="text" value="${value_of('q', default='')}"/>
   <input type="submit" value="Search"/> <input type="submit" name="all" value="All"/>
</form>
${hits} ${items} found
<p class="pagelist">${currentPage.pager(format='$link_first ~3~ $link_last')}</p>
<div>
  ${grid(data)}
</div>
<p><a href="${tg.url('form')}">Add a ${item}</a></p>

The searches works fine resulting in links like this ‘/list?q=cable‘ but when I click some of the paginating pages “1,2…8,9” turns to ‘/list?page=2‘

How do I add my previous query parameter or any other parameters to the link?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:28:56+00:00Added an answer on May 12, 2026 at 5:28 pm

    After experimenting on the shell for a while I think I found a solution.

    There’s a kwargs dictionary defined in currentPage (after being assigned from paginate.Page), so I made some experiments sending parameters and it worked. This is how.

    currentPage = paginate.Page(products, page, items_per_page=50)
    
    currentPage.kwargs['q'] = q
    
    return dict(currentPage=currentPage, 
        title=u'Products List', item=u'product', items=u'products',
        data=currentPage.items, 
        grid=product_grid,
        page=u'Search %s results' % q,
        q=q,
        hits=len(products))
    

    now I get this kind of links: ‘/list?q=cable&page=2‘ still wondering if it is the best solution or the best practice

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take a look at this example: http://www.extjs.com/deploy/dev/examples/multiselect/multiselect-demo.html On it, there are components rendered against
I want to have my site urls look like http://example.com/place/info?var=info&morevars=ifneeded Place and info are
I have a problem with internet explorer 6 and 7, please look this example
please look at this example of drop down checkbox list im working on.. http://jsfiddle.net/Yojik/VJHVK/143/
Take a look at this example here: http://denise.brixwork.com/showlisting/1/8297-Valley-Drive-Alpine-Meadows-Whistler-denise-brown-real-estate And the red tables under Specifications
I have some difficulties with understanding BindingSource's behaviour. Let's look at following example: Creating
I have a pagination that needs to look like that: a busy cat http://img338.imageshack.us/img338/3180/pagination.jpg
I have come across a few Perl modules that for example look similar to
Need a rope ;)) Take a look on example: I have a table: CREATE
i have a xml file on a server that look for example like this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.