Possible bug with SQLFORM.grid search and order

70 views
Skip to first unread message

Jeff Plata

unread,
Aug 1, 2023, 2:19:28 AMAug 1
to web2py-users
Possible bug when searching in SQLFORM.grid with order activated.

To reproduce:
1. SQLFORM.grid, advanced_search = True
2. Click a column header on the grid to activate 'order'
3. Click 'search' (with or without keyword)
4. Error as follows:
Traceback (most recent call last):
File "C:\Users\User\Desktop\web2py\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
File "C:/Users/User/Desktop/web2py/applications/bsmOnline/controllers/library.py", line 113, in <module>
File "C:\Users\User\Desktop\web2py\gluon\globals.py", line 430, in <lambda>
self._caller = lambda f: f()
File "C:/Users/User/Desktop/web2py/applications/bsmOnline/controllers/library.py", line 56, in region
create=can_add_library, editable=can_edit_library, deletable=can_delete_library)
File "C:\Users\User\Desktop\web2py\gluon\tools.py", line 3951, in f
return action(*a, **b)
File "C:/Users/User/Desktop/web2py/applications/bsmOnline/models/db1.py", line 78, in library
grid = SQLFORM.grid(query, maxtextlength=80, csv=False, **kwargs)
File "C:\Users\User\Desktop\web2py\gluon\sqlhtml.py", line 2804, in grid
otablename, ofieldname = order.split('~')[-1].split('.', 1)
AttributeError: 'list' object has no attribute 'split'

Upon clicking the 'search' button, it seems that the 'order' in request .vars is transformed from string to list, such that order = 'anykey' becomes 'order = ['anykey', 'anykey'], hence, the error.

Workaround for me:
if request.vars:
    if 'order' in request.vars:
        request.vars.order = request.vars.order[0]

Can somebody please confirm or am I doing something wrong?

Douglas Krueger

unread,
Aug 11, 2023, 12:55:48 PMAug 11
to web2py-users
Hello Jeff, 
I've posted a here but it seems to be pending approval. I notice no responses to your post. Is this site dead? Is Web2py dead? Did everyone go to Django? Thanks in advance for your reply. 

Clemens

unread,
Aug 11, 2023, 2:13:00 PMAug 11
to web2py-users
Hi
web2py is not dead, there are still updates, but mainly concerning security and thus stuff. And web2py is not further developed because the future of this framework is py4web.

Just have a look here to learn the difference between web2py and py4web, because they are very similar:

Best regards
Clemens

Douglas Krueger

unread,
Aug 11, 2023, 3:30:18 PMAug 11
to web2py-users
Thank you Clemens, 
The differences between web2py and py4web seem minor. Would you suggest new folks start with Py4web?  

Many thanks, 
Doug 

Clemens

unread,
Aug 12, 2023, 7:47:01 AMAug 12
to web2py-users
Hi Jeff,

if you're just starting up, I would suggest to use py4web, since it is the future. I'm still using web2py because I've developed there a bigger system. But sooner or later I'm gonna migrate my system to py4web.

And btw I really like web2py and thus I like py4web too. The community is very active but is already migrated to py4web ;-) Thus, start with py4web.

Best regards
Clemens

Douglas Krueger

unread,
Aug 12, 2023, 2:36:50 PMAug 12
to web2py-users
HI Clemens, 

I noticed the latest post in the py4web label is 3 years old. Where could I find the latest py4web posts? 

thanks again, 
Doug 

Clemens

unread,
Aug 12, 2023, 4:54:55 PMAug 12
to web2py-users

Jim S

unread,
Aug 14, 2023, 1:00:22 PMAug 14
to web2py-users
@doug - I would highly recommend looking at py4web over web2py.  web2py is a fantastic tool, but seems its time has passed.  py4web uses lots of the same concepts and tools, but is re-architected to be more efficient.  There are a few of us that usually always active on the py4web site.  Massimo is around a lot to look at questions and help out with answers.

-Jim

Reply all
Reply to author
Forward
0 new messages