[Zope] LocalFS and PathHandler

Dieter Maurer dieter@handshake.de
Tue, 23 Jan 2001 23:11:48 +0100 (CET)


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