Hello, I try to access LocalFS from my own DTML method. (Exactly from my PathHandler method.) I got all directory information in one array like this path_to_handle = ['sub1', 'sub2', 'sub3'] How can a get a directory listining with LocalFS for path "/sub1/sub2/sub3/"? I know I need something like "lfs['sub1']['sub2']['sub3'].fileids". But what if there are more (or less) elements in path_to_handle? I hope made my point clear? Thanks Ulli -- Searchengine Know How - Webpromotion - Optimization - Internal Search World Wide Web Publisher, Ulrich Wisser, Odensvag 13, S-14571 Norsborg http://www.publisher.de Tel: +46-8-53460905 Fax: +46-8-534 609 06
On Mon, 22 Jan 2001, Ulrich Wisser wrote:
I try to access LocalFS from my own DTML method. (Exactly from my PathHandler method.) I got all directory information in one array like this
path_to_handle = ['sub1', 'sub2', 'sub3']
How can a get a directory listining with LocalFS for path "/sub1/sub2/sub3/"? I know I need something like "lfs['sub1']['sub2']['sub3'].fileids". But what if there are more (or less) elements in path_to_handle?
I would write it in python, as a recursive function: def goo(lfs, path_to_handle): if len(path_to_handle)==0: return lfs else: lfs=lfs[path_to_handle[0]] path_to_handle=path_to_handle[1:] return goo(lfs, path_to_handle) ololo@zeus.polsl.gliwice.pl, oleks@helper.pl /--------------------------------------\ | `long long long' is too long for GCC | \--------------------------------------/
Ulrich Wisser wrote:
Hello,
I try to access LocalFS from my own DTML method. (Exactly from my PathHandler method.) I got all directory information in one array like this
path_to_handle = ['sub1', 'sub2', 'sub3']
How can a get a directory listining with LocalFS for path "/sub1/sub2/sub3/"? I know I need something like "lfs['sub1']['sub2']['sub3'].fileids".
Hmmm... try this as a Python (Script|Method|External Method), don't try and do it in DTML ;-) object = lfs for id in path_to_handle: object = object.get(id) return object.fileids you could probably turn that into a one liner with reduce: return reduce(lamda x,y: x.get(y), [lfs]+path_to_handle).fileids I'd laugh loads if you could do that in DTML: <dtml-var "reduce(lamda x,y: x.get(y), path_to_handle, lfs).fileids"> Who said you can't write obfuscated python? *grinz* Chris PS: The first method should work, the one may work through sheer fluke, neither have been tested though... PPS: Nice to see someone using PathHandler :-)
participants (3)
-
Aleksander Salwa -
Chris Withers -
Ulrich Wisser