[Zope] case insensitive search?
Aleksander Salwa
ololo@zeus.polsl.gliwice.pl
Wed, 3 Jan 2001 09:36:44 +0100 (MET)
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))