Right, use a python method, with a regular expression, like:

import regsub
def stringchange(self):
        """
        Accepts a string passed as self, modifies it 
        using a regex substitution, and returns modified
         This example strips multiple spaces, puts in a single one
        """
        result=regsub.gsub('[ \t][ \t]+', ' ', self)
        return result

You could use regsub.sub to replace the first instance of a pattern in a
string, or regsub.gsub to do all.  Look in /lib/python1.5/regsub.py to see
all the regular expression substitution functions avalable.  The regex
syntax is pretty vanilla; (i.e. chapter 1 of the book _Mastering Regular
Expressions_ has enough detail to use regular expressions well enough in
python).  There is also a split function in regsub.py that might be of use
here, using the '/' as the delimiter pattern; I think you would use it like
this:

mylist = regsub.split(self, '/')

You could then write your function to get a particular item, like city,
language, etc by obtaining the slices from mylist.

Good luck,
Sean

-----Original Message-----
From: Ivan Cornell [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 26, 2001 2:40 AM
To: Fabien Germain
Cc: [EMAIL PROTECTED]
Subject: Re: [Zope] Problem : ZCatalog


Fabien Germain wrote:

> Hello,
>
> I've got a problem with a search form.
>
> I have a ZCatalog with lots of entries. I added the index
> "absolute_url" in
> order to search by the files url.
>
> Why ?
> 'cause I have files in organized folders like that :
> ......../language_name/country_name/city_name/element
>
> I'd like to do a search on "#language_name and #country_name and
> #city_name"
> in my catalog, so I use the absolute_url.
> But the problem is that the search only looks the end of the
> absolute_url
> string, that's to say "element" in my exemple.
>
> How could I search in all the string ?

Well, my solution would be to create a python method that splits your
url up into indexable words and then index this method in ZCatalog. One
of cool features of the ZCatalog is that it can index objects methods.

Hope this helps

Ivan

PS Please send text only mail to the list -you'll probably get more
replies if you do!


_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
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 )

_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
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 )

Reply via email to