Re: [Zope] LocalFS and PathHandler
Ulrich Wisser writes:
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? The easiest answer to these types of questions are recursive functions.
You may use a "dtml-in", too. Like that: <dtml-call "REQUEST.set(curr__,lfs)"> <dtml-in path_to_handle> <dtml-call "REQUEST.set(curr__,curr__[_['sequence-item']])"> </dtml-in> <dtml-var "curr__.fileids"> Dieter
Hello,
At 19:54 22.01.2001 +0100, Dieter Maurer wrote:
Ulrich Wisser writes:
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? The easiest answer to these types of questions are recursive functions.
[...]
this is the code I came up with: <dtml-call "REQUEST.set('mylfs',lfs)"> <dtml-in path_to_handle> <dtml-call "REQUEST.set('mylfs',mylfs[_['sequence-item']])"> </dtml-in> Now I should have a reference to the object in mylfs. How can I detect if mylfs is a file or a directory? Thanks Ulrich -- 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
Ulrich Wisser writes:
How can I detect if mylfs is a file or a directory? I fear that is a difficult question.
For unknown reasons, the builtin Python function "type" is considered unsafe (and would not help anyway). Thus, you cannot test for types. In PythonScript you have the function "same_type" that can be used to check whether two type are identical. I do not know, how well this function works with acquisition wrappers. There there is "isinstance". As I heard (but did not verify) there should be problems with ExtensionClass and Acquisition, as well. Thus, I would not try to determine, whether it is a directory or file. Instead, I would go for the interface based approach. Ask yourself, what operations you would need for a directory or file, respectively. Check for these operations to differenciate between the two. Dieter
participants (3)
-
Dieter Maurer -
Jonothan Farr -
Ulrich Wisser