Hello zopers! help me please! Please please ! I have some folders like this: grandfolder folder1 popup.jpg thumbpopup.jpg thumbpopup_over.jpg genericalFile folder2 popup.jpg thumbpopup.jpg thumbpopup_over.jpg genericalFile folder3 genericalFile !! note that the folder3 has NO *popup.jpg files !! Now: <dtml-in prefix="folder" expr="grandfolder.objectValues()"> <td> <a href="#" onMouseOut="MM_swapImgRestore(); sfondo(1,'#FFFFFF')" onMouseOver="sfondo(1,'#CCFFCC'); MM_swapImage('<dtml-var pezzo_item>/thumbpopup.jpg','','<dtml-var pezzo_item>/thumbpopup_over.jpg',1)" onClick="MM_openBrWindow('<dtml-var pezzo_item>/popup.jpg','26NG1103145','width=315,height=265')"> <img border="0" src="<dtml-var pezzo_item>/thumbpopup.jpg" width="60" height="50"></a> </td> The problem is that in folder3 it provides a path to some nonexistent files! I should check wether the folder_item has got the *popup.jpg files and draw this cell (<td></td>) ONLY if it has got them, otherwise I shouldn't. How do I check wether a folder contains a given file? i tried "folder_item['thumb.jpg']" but when it reaches a folder that doesn't contain a 'thumb.jpg' file it breaks! I tried has_key('thumb.jpg'), hasKey('thumb.jpg') with no success! Still, the error it raises when reaching the folder3 folder is KeyError. Thanks SO much ! Bye Catonano
Catonano wrote:
How do I check wether a folder contains a given file? i tried "folder_item['thumb.jpg']" but when it reaches a folder that doesn't contain a 'thumb.jpg' file it breaks! I tried has_key('thumb.jpg'), hasKey('thumb.jpg') with no success!
Hi, try: _.hasattr(yourFolderToTestAsAnObject, 'thumb.jpg') If you use this in a PythonScript, remove the '_.' Cheers, maik
participants (2)
-
Catonano -
Maik Jablonski