We had to make some changes to paginate.py. Specifically we added the following code into class Paginate in the __init__(). It wraps the  incoming list and dict structures so that the GET url used on the links can handle the nested structures. A colleague of my has a version that is recursive. The code here only goes a level deep. It was needed to pass form data along with the pagination. It's taken from Randall's patch for pagination.

Look at http://trac.turbogears.org/turbogears/ticket/1115 for more.

...
        # If we have a nested dict from a form, it must be denormalized before
        # it can be put into a GET URL.
        #     {'form_field':{'text':'hello', 'hidden':''}
        # Goes to:
        #     {'form_field.text':'hello', 'form_field.hidden':''}
        # I'm going to be specific so as to minimize breakage.
        #
        #  -- Nicky's change. Break out lists like Randall did for dicts.
        for (ikey, ivalue) in input_values.items():
            if isinstance(ivalue, dict) and len(ivalue) > 1:
                del input_values[ikey]
                for (sub_ikey, sub_ivalue) in ivalue.items():
                    if isinstance(sub_ivalue, list) and len(ivalue) > 1 :
                        for idx, sub_sub_ivalue in enumerate (sub_ivalue):
                            new_key ='%s.%s-%d' % (ikey,sub_ikey,idx) # Magic list format
                            input_values[new_key] = sub_sub_ivalue
                    else:
                        new_key = '%s.%s' % (ikey, sub_ikey)
                        input_values[new_key] = sub_ivalue
# This is probable needed for completeness...
            if isinstance(ivalue, list) and len(ivalue) > 1 :
                for idx, sub_ivalue in enumerate (ivalue):
                    new_key ='%s-%d' % (ikey,idx) # Magic list format
                    input_values[new_key] = sub_ivalue
                


On 10/8/06, Talin <[EMAIL PROTECTED]> wrote:

OK I've spent about an hour searching the docs and looking at the
source code to the paginate decorator, and I can't figure this one out.

How do I use paginate in conjunction with a controller method that
takes multiple parameters? I have a search page that takes a url in the
form "page.html?search=xxx". I'd like to be able to use the pagination
decorator - however, I can't figure out how to get the pagination
decorator to combine my "search=" query parameter with its own query
params.You would think that get_href would take optional params
indicating additional query params - just like tg.url does.

(And you can't use tg.url to glue together the pagination url and your
own query, because that just adds an extra '?' making the URL invalid.)

-- Talin





--
--
Nicky Ayoub
G-Mail Account
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to