[Zope] I need a clue

Joseph A Knapka jknapka@earthlink.net
Wed, 13 Mar 2002 00:38:40 +0000


Jeff Nielsen / UgoFast wrote:
> 
> I'm trying to do a rather simple thing, I think, but I can't get it to
> work right. If someone can point out where I'm going astray, it would be
> appreciated. I'm trying to iterate over a list of files in a LocalFS
> subdirectory, and then write out some html if the files end in .gif or
> .jpg. Something like this:
> 
> <dtml-in "images[FSSession['LoginCompanyImagesPath']].fileIds()">
>   <dtml-if "_.string.find('sequence-item','.gif') >= 0 or
> _.string.find('sequence-item','.jpg') >= 0">
>     ..do some things if a .gif or .jpg file
>   </dtml-if>
> </dtml-in>
> 
> However, the find always returns -1, regradless of whether the
> sequence-item has .gif or.jpg in it. I'm baffled.

'.gif' doesn't appear in (the literal string) 'sequence-item'.
Possibly you should try:

<dtml-in "images[FSSession['LoginCompanyImagesPath']].fileIds()">
  <dtml-if "_.string.find(_['sequence-item'],'.gif') >= 0 or
_.string.find(_['sequence-item'],'.jpg') >= 0">
    ..do some things if a .gif or .jpg file
  </dtml-if>
</dtml-in>

(You no doubt figured that out about eighteen seconds
after posting that message :-)

Cheers,

-- Joe
  Using open-source software: free.
  Pissing Bill Gates off: priceless.