James van der Veen wrote:
Hi everybody,
I have a question most of you will probably know the awnser of...So les't start.
I have a site where people can add information of a company this gets into the catalog. I have all the letters of thre alphabeth listed. Now if a person clicks the letter I would want to search for all the companys with starting letter the person just clicked.
So I guess my question is how can I search for the fist letter of a sting in the catalog.
Can somone help me with this?
Greetz, James
Although TextIndexes support something like this, I doubt they would work the way you want if the string contains multiple words. I think the way to do it is to create a method or python script that returns the first letter of the property and index on it. Lets say your property is called spam, create a script (as a method of the ZClass if it is one or just in the Zope roo folder) called 'first_letter_of_spam' or some such. The following line of code will return the first letter: return context.spam[0] of if it is a ZClass method: return container.spam[0] Then create a FieldIndex in your ZCatalog called first_letter_of_spam (matching the script name) and update the catalog. Then you can easily formulate a search by first letter. hth, -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>