You can get these parameters from original request stored in
cherrypy.request.params (or something like that RTFM)
On 12 avr, 23:53, "yoanis_gil" <[EMAIL PROTECTED]> wrote:
> So after a couple of thoughs i found a possible solution: decorators.
> The idea is to intercept parameters transfered to @paginate.Here is
> the decorator:
>
> def copyparms(*to_copy):
> import turbogears.decorator
> from turbogears.decorator import weak_signature_decorator
> # @weak_signature_decorator
> def decorator(f):
> def internal(*args,**kwds):
> for old,new in to_copy:
> if old in kwds:
> kwds[new] = kwds[old]
> return f(*args,**kwds)
> return internal
> return decorator
>
> Then all we need is to declare @copyparams before @paginate.
> Something like this:
> @copyparms(("tg_paginate_order","order_by_field"))
> @paginate('mb_stats',default_order=BY_BYTES)
> def
> mbstats(self,area_id,uclass,stats_by_field,order_by_field=BY_BYTES):
> pass
>
> If anybody is interested i can sent him(her) the code.
>
> On Apr 12, 3:29 pm, "yoanis_gil" <[EMAIL PROTECTED]> wrote:
>
> > I wanted a sortable and paginated datagrid so i decided to use
> > PaginateDatagrid. Since i'm not using SqlObject and i want to display
> > a list of tuples, I don't get elements sorted. That's ok. This is how
> > i defined my datagrid:
>
> > mb_stats_datagrid = PaginateDataGrid(fields=[
> > PaginateDataGrid.Column(name='usuario',
> > getter=lambda row: row[0], title='Usuario'),
>
> > PaginateDataGrid.Column(name=BY_MSG_COUNT,getter=lambda row: row[1],
> > title='Cantidad',options=dict(sortable=True)),
>
> > PaginateDataGrid.Column(name=BY_BYTES,getter=lambda row: row[2],
> > title='Peso',options=dict(sortable=True))])
>
> > I notice that columns headers from the rendered datagrid contains a
> > param which specifies which column is to be sorted. The param is named
> > *tg_paginate_order*. That's when i figured out how to get my data
> > sorted. I just needed access to that param. But ...
> > Looking at paginate.py. I found this:
>
> > page = int(kw.pop('tg_paginate_no', 1))
> > limit_ = int(kw.pop('tg_paginate_limit', limit))
> > order = kw.pop('tg_paginate_order', default_order)
> > reversed = kw.pop('tg_paginate_reversed', None)
>
> > Yes, :( that was really sad. I know that most of those variables are
> > not relevant for the function been decorated. But if there's a way of
> > knowing the sorting parameter then paginate parameter becomes even
> > more generic.
>
> > I guess i will have to find a way of keeping that parameter.
>
> > Regards ...
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---