how to fix this code problem?
''''code 1 index_html <html> <body> <table > <tr tal:repeat="item container/objectValues"> <td tal:content="item/getId">Sample.tgz</td> </tr> </table> </body> </html> with above code when i hit test index_html i get following result which are all files and sub-directoy on current folder index_html ''' a file myfiles ''' a file Files ''' a folder I am now tring to use python script to show all file I put two files on current diectroy '''' index_html <html> <body> <table > <tr tal:repeat="item container/myfiles"> <td tal:content="item/getId">Sample.tgz</td> </tr> </table> </body> </html> and a python file '''myfiles return container.objectValues('File') when i test index_html i expect to get a list of two files index.html and myfiles. but disponitedly it return nothing!! how can i fix this problem? Thanks
'''' index_html <html>
<body> <table > <tr tal:repeat="item container/myfiles"> <td tal:content="item/getId">Sample.tgz</td> </tr>
</table>
</body> </html>
and a python file '''myfiles return container.objectValues('File')
You call the "myfiles" script on the container object, and then you call "container.objectValues", which will return the objectValues of the containers container. Maybe return context.objectValues('File') would work better?
index_html ''' a file myfiles ''' a file Files ''' a folder
I believe that index_html and myfiles are not files, but something like DTML Method and Script (Python). If you think that "everything which is not a folder is a file" - you think wrong. If you want a list of all non-folderish objects, you should search google for something like isPrincipiaFolderish (don't remember exact name) or check for existense of objectValues method of every object. Also, i think that you should change all occurences of "container" to "context" or "here" to make your script really useful :)
participants (3)
-
Jianping Zhu -
Lennart Regebro -
Sergey Volobuev