[Zope] Traversing LocalFS
J Cameron Cooper
jccooper@jcameroncooper.com
Fri, 25 Apr 2003 13:36:50 -0500
> Premise: Create a method of displaying files (in browser with URL
> linking) from a Local File System in Zope that can
> be traversed.
>
> I have already installed the LocalFS product and it seems to work
> fine, as least for
> the first level of file/folders. But I need to be able to traverse
> down an infinite (well a lot)
> number of directories so that users can select a specific file. Like
> I said the first level is
> easy since I am in the "Zope Environment", but I can not figure out
> how to
> keep traversing the path (URL Link) once I have moved out of the Zope
> system and into the
> LocalFS. I have been unable to add a DTML file in the LocalFS to load
> the next level, or at least I can't figure out how.
> ...
Digging out an old tree-walker experiment:
This is in a ZPT named 'recurse' somewhere above whatever you want to list::
<ul>
<li tal:repeat="item here/objectValues">
<span tal:content="item/getId" tal:omit-tag="">An object</span> :
<span tal:content="item/title" tal:omit-tag="">A title</span>
<span tal:condition="python:item.meta_type=='Folder'"
tal:content="structure item/recurse">A Folder listing</span>
</li>
</ul>
It can be used like::
<div tal:replace="structure here/recurse">ASDF</div>
It's not DTML, I know, but you should be able to either deal with the
ZPT or translate it, as it's not that complex. I haven't tried it on
LocalFS, but so long as it uses objectValues to list its objects (and
I'm pretty sure it does) everything should work fine. You may have to
change the meta_type in the condition if LocalFS doesn't use Folder
(though, again, I think it does.)
--jcc