Is there an easy way to make the Find tab case insensitive. It seems like a very common need, but I see that FindSupport.py is calling string.find which makes it seem as though this is harder than it should be. -- Robin Becker
On Wed, 3 Jan 2001, Robin Becker wrote:
Is there an easy way to make the Find tab case insensitive. It seems like a very common need, but I see that FindSupport.py is calling string.find which makes it seem as though this is harder than it should be.
You can try my very quick patch, attached below. But beware - it gives much more that you want - it is full regexp search. --- FindSupport.py Wed Jul 26 16:11:54 2000 +++ FindSupport_caseIns.py Wed Jan 3 09:33:34 2001 @@ -92,7 +92,7 @@ from Globals import HTMLFile from DocumentTemplate.DT_Util import InstanceDict, TemplateDict from DateTime import DateTime -from string import find +from re import search, IGNORECASE from AccessControl import getSecurityManager class FindSupport(ExtensionClass.Base): @@ -177,7 +177,8 @@ and (not obj_searchterm or (hasattr(ob, 'PrincipiaSearchSource') and - find(ob.PrincipiaSearchSource(), obj_searchterm) >= 0 + search(obj_searchterm, ob.PrincipiaSearchSource(), + IGNORECASE) != None )) and (not obj_expr or expr_match(ob, obj_expr)) @@ -269,7 +270,8 @@ and (not obj_searchterm or (hasattr(ob, 'PrincipiaSearchSource') and - find(ob.PrincipiaSearchSource(), obj_searchterm) >= 0 + search(obj_searchterm, ob.PrincipiaSearchSource(), + IGNORECASE) != None )) and (not obj_expr or expr_match(ob, obj_expr))
A less easy way is to patch dtml-in so its allows sorts where it is case insensitive. Theres a simple patch for this here: http://www.zope.org/Members/andym/IgnoreCase Then patch the findResult.dtml, dtml source: lib\python\OFS\findResult.dtml line 44: <dtml-in results sort ignore_case> This will allow you to fix any management screen/sort using dtml-in to be case insensitive. There are other options of course. -- Andy McKay, Developer. ActiveState. ----- Original Message ----- From: "Robin Becker" <robin@jessikat.fsnet.co.uk> To: <zope@zope.org> Sent: Tuesday, January 02, 2001 5:16 PM Subject: [Zope] case insensitive search?
Is there an easy way to make the Find tab case insensitive. It seems like a very common need, but I see that FindSupport.py is calling string.find which makes it seem as though this is harder than it should be. -- Robin Becker
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Wed, 3 Jan 2001, Robin Becker wrote:
Is there an easy way to make the Find tab case insensitive. It seems like a very common need, but I see that FindSupport.py is calling string.find which makes it seem as though this is harder than it should be.
Now, I did it better way. No regular expressions. Just case-insensitive search. "Case insensitive" checkbox on "Find" form. If you need it - just take a look at an attachment. Maybe I will send it to the Collector... ololo@zeus.polsl.gliwice.pl, oleks@helper.pl /--------------------------------------\ | `long long long' is too long for GCC | \--------------------------------------/
Is there an easy way to make the Find tab case insensitive. It seems like a very common need, but I see that FindSupport.py is calling string.find which makes it seem as though this is harder than it should be.
Now, I did it better way. No regular expressions. Just case-insensitive search. "Case insensitive" checkbox on "Find" form. If you need it - just take a look at an attachment. Maybe I will send it to the Collector...
The checkbox is good, but surely the patch should be in presentation layer (dtml-in) and not just in Find Support. My patch fixes it throughout Zope... -- Andy McKay, Developer. ActiveState.
Andy McKay wrote:
The checkbox is good, but surely the patch should be in presentation layer (dtml-in) and not just in Find Support. My patch fixes it throughout Zope...
Hangon... I think this is case insensitive search, not sort ;-) eg: when searching for 'fIsh', that would return objects containing 'fish', 'fIsh' and 'fiSH'. Not sure how your patch helps here, but I'm probably being stupid :-) cheers, Chris
No im being stupid and did a replace of sort for search in my caffeine deprived brain. -- Andy McKay, Developer. ActiveState. ----- Original Message ----- From: "Chris Withers" <chrisw@nipltd.com> To: "Andy McKay" <andym@activestate.com> Cc: "Aleksander Salwa" <ololo@zeus.polsl.gliwice.pl>; <zope@zope.org> Sent: Thursday, January 04, 2001 2:00 AM Subject: Re: [Zope] case insensitive search?
Andy McKay wrote:
The checkbox is good, but surely the patch should be in presentation
layer
(dtml-in) and not just in Find Support. My patch fixes it throughout Zope...
Hangon... I think this is case insensitive search, not sort ;-)
eg: when searching for 'fIsh', that would return objects containing 'fish', 'fIsh' and 'fiSH'.
Not sure how your patch helps here, but I'm probably being stupid :-)
cheers,
Chris
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
In article <00c601c0766e$c8280540$ae03a8c0@fork>, Andy McKay <andym@ActiveState.com> writes
No im being stupid and did a replace of sort for search in my caffeine deprived brain. -- Andy McKay, Developer. ActiveState.
... nevEr miNd we're all a BIt dUMb nOW and THEn :) -- Robin Becker
In article <Pine.LNX.4.21.0101032012320.775-101000@localhost>, Aleksander Salwa <ololo@zeus.polsl.gliwice.pl> writes
On Wed, 3 Jan 2001, Robin Becker wrote:
Is there an easy way to make the Find tab case insensitive. It seems like a very common need, but I see that FindSupport.py is calling string.find which makes it seem as though this is harder than it should be.
Now, I did it better way. No regular expressions. Just case-insensitive search. "Case insensitive" checkbox on "Find" form. If you need it - just take a look at an attachment. Maybe I will send it to the Collector...
ololo@zeus.polsl.gliwice.pl, oleks@helper.pl
/--------------------------------------\ | `long long long' is too long for GCC | \--------------------------------------/
[ A MIME APPLICATION / x-gtar part was included here. ]
that looks like a nice way to do it, but I reckon we could make the lambda stuff a bit cleverer ie modify the default find eg if search_caseins: FINDER = lambda ob,p=lower(obj_searchterm): find(lower(ob.PrincipiaSearchSource()),p) else: FINDER = lambda ob,p=obj_searchterm: find(ob.PrincipiaSearchSource(), p) and then we use FINDER(ob) -- Robin Becker
participants (4)
-
Aleksander Salwa -
Andy McKay -
Chris Withers -
Robin Becker