AMAZING !  I took the patch in #1115 and replaced the encoding with the formencode version. Works like a charm.
I had as sneaky suspicion that the code was in there somewhere...
Thanks for the tip!

In the standard paginate.py I added the following as the first line of Paginate.__init__():
input_values = variable_encode(input_values)
Don't forget to import...

Nicky

On 10/9/06, Alberto Valverde <[EMAIL PROTECTED]> wrote:

On Oct 9, 2006, at 4:29 PM, Nicky Ayoub wrote:

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

I'd strongly suggest using formencode.variabledecode.variable_encode for encoding the data NestedVariables decodes (using formencode.variabledecode.variable_decode) from the request parameters in TG's filter. 

Just in case one day this encoding format changes in FE (and to avoid wheel reinvention ;) )
Alberto





--
--
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