Easy to Understand SQLFORM.grid Custom Search

136 views
Skip to first unread message

JoeCodeswell

unread,
Jul 10, 2014, 12:09:10 PM7/10/14
to web...@googlegroups.com
Dear web2py-users,

I have written a recipe to customize the SQLFORM.grid search WITHOUT the need to specify a custom search_widget and so needing to read & understand the clever web2py implementation source code.

The maintained link to the recipe is here on joecodeswell.wordpress.com. An older version is available on web2pyslices.com.

Thanks for a GREAT framework and a GREAT community.

Love and peace,

Joe

Vinicius Assef

unread,
Jul 10, 2014, 3:10:27 PM7/10/14
to web2py
Really good.

How about updating the web2pyslices version, too? ;-)
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

peter

unread,
Jul 10, 2014, 7:20:39 PM7/10/14
to web...@googlegroups.com
Thanks for this Joe, and it is an interesting approach. However I find the approach I used


Somewhat easier to understand. Your approach is more novel however. 

Peter

JoeCodeswell

unread,
Jul 11, 2014, 11:33:10 AM7/11/14
to web...@googlegroups.com
Dear viniciusban,

Thanks for the comment.

You also said, "
How about updating the web2pyslices version, too? ;-) ".

DONE!  :)

Thanks again, viniciusban.
Love and peace,
Joe

JoeCodeswell

unread,
Jul 11, 2014, 11:42:53 AM7/11/14
to web...@googlegroups.com
Dear peter,

Thanks for the reply. I have used your post in the past. Reading it and reading the gluon code actually helped me get a grid Custom Search WITH a search_widget specified in the grid function arguments.

Thanks again, peter.

Love and peace,

Joe

Vinicius Assef

unread,
Jul 11, 2014, 11:49:09 AM7/11/14
to web2py
Nice. :-)

villas

unread,
Jul 12, 2014, 1:39:31 PM7/12/14
to web...@googlegroups.com
I would also like to add an optional 'extra' because it is nice to be able to search like this:

    search_text = '"David Cameron" uk' 

By quoting search 'phrases' as well as words,  you can get a better result.  After all,  I would not want every David in the UK to be listed.

I have found that using 'shlex' is a good solution.  For example:

    import shlex 
    words = [x for x in shlex.split(search_text)] if search_text else []

I hope this might also be useful to someone wishing to improve their search options.

D

JoeCodeswell

unread,
Jul 14, 2014, 12:54:27 PM7/14/14
to web...@googlegroups.com
Dear villas,

Thanks for the reply.

Here is my understanding of what you want. You'd like to be able to search using a search syntax based on the shlex module.

My technique uses the SQLFORM.grid's Standard Search Input ("#w2p_keywords") syntax for it's searches.

I suggest you post an Enhancment suggestion for the SQLFORM.grid's Standard Search Input as a main discussion topic in this forum.

Thanks again, villas.

Love and peace,

Joe

villas

unread,
Jul 21, 2014, 11:25:24 AM7/21/14
to web...@googlegroups.com
Hi Joe,

I suppose that my proposal to use shlex would really apply to Peter's suggestion.  

I guess it might also be considered for use in the build_query function of sqlhtml.py.

Shlex seems like a great way of using quotes to contain search phrases.  I guess Google would be using something similar,  and I'm sure that many of us use that feature all the time.

JoeCodeswell

unread,
Jul 25, 2014, 11:37:59 AM7/25/14
to web...@googlegroups.com
Dear villas,


You said:


I suppose that my proposal to use shlex would really apply to Peter's suggestion.  

I guess it might also be considered for use in the build_query function of sqlhtml.py.

Shlex seems like a great way of using quotes to contain search phrases.  I guess Google would be using something similar,  and I'm sure that many of us use that feature all the time.


I think you're right on all accounts. Maybe you should post an "Enhancement" request to  Issues-web2py for "the build_query function of sqlhtml.py".

Love and peace,

Joe
Reply all
Reply to author
Forward
0 new messages