[Zope] FQ Path Names in container

J Cameron Cooper jccooper@jcameroncooper.com
Wed Aug 6 20:40:46 EDT 2003


>
>
>I have  no problem accessing a given file, even if it has a .extension; my
>problem is trying to figure out how to do traversal and require it to be
>from the root folder, rather starting at the current directory.  In other
>words, yes, I can do this:
>container.restrictedTraverse('A/B/C.pdf')
>But what I want to be able to do is:
>container.restrictedTraverse('/A/B/C.pdf').  Note the leading '/' before 'A'
>  
>
restrictedTraverse can deal with relative and absolute paths. You can 
check out how it is done in

http://cvs.zope.org/Zope/lib/python/OFS/Traversable.py?rev=HEAD&content-type=text/vnd.viewcvs-markup

>And, err, 'nevermind' -- I figured I might as well trawl ZopeLabs (I didn't
>know about them until you sent the links above), and found 'get Root
>Object', cookbook recipe #994090604.  That should do the trick.
>  
>
That recipe can also be written like

obj.restrictedTraverse("/")

since the path can be a Unixish path or a list/tuple of strings. (It 
even knows that '..' is 'parent of'.)

             --jcc

-- 
"My point and period will be throughly wrought,
Or well or ill, as this day's battle's fought."






More information about the Zope mailing list