I've worked with paginate.py and had troubles as noted here:

http://groups.google.com/group/turbogears/browse_thread/thread/a72609b64f365d/44e54f81d348ca67?lnk=gst&q=pagination&rnum=1#44e54f81d348ca67

I decided that moving the submitted form data out of the URL and into a
session would solve those issues and also allow for more features.
Being new to decorators I looked over the TG decorator code and also
did some reading here:

http://www.phyast.pitt.edu/~micheles/python/documentation.html#introduction

The paginate.py code uses the weak_signature_decorator function to
allow extra keyword arguments and is structured like so:

def paginate(*args, **kwargs):
    def entable(func):
        def decorated(func, *args, **kwargs):  # <-- My problem is here
            # Do some stuff
            output = func(args, kwargs)
            # Do some stuff
            return output
        return decorated
    return weak_signature_decorator(entable)

Note the line I marked above (def decorated ...).  I'm still not quite
sure what the state of the input is here with respect to the decorated
function.   The decorated function looks like this:

    @expose(template="paginatetest.templates.search_results")
    @validate(form=search_form)
    @paginate('results', default_order='name')
    def searchResults(self, test_field='Somebody'):
        # do stuff

I thought at first *args and **kwargs were received just before they
were given to the decorated function, but that can't be true because if
test_field is not given I get the default 'Somebody'.  On top of that,
when this occurs:

    output = func(args, kwargs)

I get a formencode validation error.  So it looks like the @validate
decorator is taking effect when func is called within the paginate
decorator and is using the form's validator (validator for
AutoCompleteField) to try and validate a unicode string ('Somebody').

So at this point I'm confused about how the decorators are supposed to
work and how they are supposed to work together.

Randall


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