I asked in IRC channel, but no one is using paginate decorator... :/
It is very handy an I can not belive that no one is using it (and it
works).
Is there another way to do pagination using TG? Will the paginate
decorator be supported in future?
Thanx
Jiri
Here is a patch again:
Index: turbogears/paginate.py
===================================================================
--- turbogears/paginate.py (revision 1629)
+++ turbogears/paginate.py (working copy)
@@ -14,10 +14,11 @@
allow_limit_override=False, max_pages=5):
def entangle(func):
def decorated(func, *args, **kw):
- 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)
+ crp = cherrypy.request.params
+ page = int(crp.pop('tg_paginate_no', 1))
+ limit_ = int(crp.pop('tg_paginate_limit', limit))
+ order = crp.pop('tg_paginate_order', default_order)
+ reversed = crp.pop('tg_paginate_reversed', None)
if not allow_limit_override:
limit_ = limit
Hi to all,
according to ticket #1013
( http://trac.turbogears.org/turbogears/ticket/1013") I still can not
get paginate decorator working without patch.
I asked in IRC channel, but no one is using paginate decorator... :/
It is very handy an I can not belive that no one is using it (and it
works).
Is there another way to do pagination using TG? Will the paginate
decorator be supported in future?
Thanx
Jiri
Here is a patch again:
Index: turbogears/paginate.py
===================================================================
--- turbogears/paginate.py (revision 1629)
+++ turbogears/paginate.py (working copy)
@@ -14,10 +14,11 @@
allow_limit_override=False, max_pages=5):
def entangle(func):
def decorated(func, *args, **kw):
- 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)
Hi to all,
according to ticket #1013
( http://trac.turbogears.org/turbogears/ticket/1013") I still can not
get paginate decorator working without patch.
I asked in IRC channel, but no one is using paginate decorator... :/
It is very handy an I can not belive that no one is using it (and it
works).
Is there another way to do pagination using TG? Will the paginate
decorator be supported in future?
Thanx
Jiri
Here is a patch again:
Index: turbogears/paginate.py
===================================================================
--- turbogears/paginate.py (revision 1629)
+++ turbogears/paginate.py (working copy)
@@ -14,10 +14,11 @@
allow_limit_override=False, max_pages=5):
def entangle(func):
def decorated(func, *args, **kw):
- 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)
Example URL when I click on the 'f3' field link:
And again:
http://localhost:8080/?tg_paginate_limit=10&tg_paginate_no=1&tg_paginate_order=f3
Here is the controller bit:
@expose(template="tgstark.templates.index")
@paginate('data', default_order='f1')
def index(self, **kwarg):
import time
data = []
for i in range(100):
data.append(dict(f1=str(i), f2=str(i), f3=str(100 - i)))
return dict(grid=data_grid, data=data)
And the widget bit:
from turbogears.widgets.datagrid import PaginateDataGrid from
turbogears.widgets.datagrid import DataGrid
def createDataGrid():
Column = DataGrid.Column
def get(fieldname):
return lambda x: x.get(fieldname)
options = {'sortable':True}
fields = [
Column(name='f1', getter=get('f1'), title='f1',
options=options),
Column(name='f2', getter=get('f2'), title='f2',
options=options),
Column(name='f3', getter=get('f3'), title='f3',
options=options)
]
grid = PaginateDataGrid(fields=fields)
return grid
data_grid = createDataGrid()
Any idea what I'm doing wrong?
> I see that you can get at paginate from within a template, but how do I
> get at the values from within the decorated controller method?
Old messages from this thread have already expired here... Can you explain a
bit better? If it is any value passed to your controller then it should be
available in one of your parameters to the function that is handling the
action. In my case here it is usually a dictionary "kwords".
--
Jorge Godoy <jgo...@gmail.com>
Randall
The method is heavily decorated and includes valdation:
@expose(template="tgwater.planreview.templates.search_results")
@validate(form=createSearchForm)
@error_handler(search)
@paginate('projects', default_order='id')
def searchResults(self, **data):
#stuff
My validation is a FormEncode Schema defined for the form.
All works on the same post, but when following a link to a new page, I
get errors like this:
File
"/usr/lib/python2.4/site-packages/FormEncode-0.5.1-py2.4.egg/formencode/schema.py",
line 116, in _to_python
for name, value in value_dict.items():
AttributeError: 'unicode' object has no attribute 'items'
Seems like the arguments passed in the URL are not being marshalled.
Randall
I have AutoCompleteFields and I show them with paged datagrids. I can change
the page and keep the other part of the page intact. Maybe if you post some
code to the list or open a ticket with a quickstarted project that reproduces
your problem we could see it better...
--
Jorge Godoy <jgo...@gmail.com>
Randall
> ------=_Part_273320_8853449.1154115583443
> Content-Type: text/html; charset=ISO-8859-1
> X-Google-AttachSize: 1620
>
> <br><br><div><span class="gmail_quote">On 7/27/06, <b class="gmail_sendername">Jorge Godoy</b> <<a href="mailto:jgo...@gmail.com">jgo...@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> <br>"Randall" <<a href="mailto:ran...@tnr.cc">ran...@tnr.cc</a>> writes:<br><br>> The problem seems to be with compound widgets. Specifically, I'm using<br>> an AutoCompleteField widget. If I remove it from the form, paging
> <br>> works fine.<br><br>I have AutoCompleteFields and I show them with paged datagrids. I can change<br>the page and keep the other part of the page intact. Maybe if you post some<br>code to the list or open a ticket with a quickstarted project that reproduces
> <br>your problem we could see it better...<br><br>--<br>Jorge Godoy <<a href="mailto:jgo...@gmail.com">jgo...@gmail.com</a>><br><br><br><br></blockquote></div><br>We are also having this problem. To me it seems like the paginate urls are being constructed in such a way that the form variables are included as simple strings. Once the postback is called our validator complains because the values are now json-like strings. My guess is that since they where not marshalled through the submit process of the form, the to_python() magic never happend.
> <br><br>Jorge, would it be possible for you to show how you were able to solve the problem? <br><br>Thanks,<br clear="all"><br>-- <br>--<br>Nicky Ayoub<br>G-Mail Account
>
> ------=_Part_273320_8853449.1154115583443--