[Zope] LocalFS File Criteria

Chris Withers chrisw@nipltd.com
Sat, 10 Aug 2002 16:18:42 +0100


Jose Gerardo Amaya Giron wrote:
> 
> 1.-I'm able to display the list of files that are in my LocalFS
> directory in dtml. How can I display the files the same way as I can see
> them in my localFS, I mean not just list the files but link them to the
> real file so the browser can deal with it. I was thinking of getting the
> attributes of the file and create a link in the dtml document to the
> real file, but it seems to be a cheap solution, what do you think?
> is there a better way to do it.

Well, if you want to display them in the same way as they are in localFS, either 
use LocalFS's views, or look at their source code and see how it's done :-)

> 2.-Is there a way I can only display(list) the files following some
> criteria. I mean, for example to do something like 'ls *.pdf' or
> specifically a name, this in order to display just the files that the
> user wants. How can I do it?

I'm sure you'll be iterating over a list of files at some point while bulding up 
this page. Maybe you could do something like:

<tal:i repeat="filename here/whatever_gives_you_your_filenames">
<tal:c condition="filename.endswith('.pdf')">
...your stuff here...
</tal:c>
</tal:i>

cheers,

Chris