[Zope] DTML Document Properties strangeness

Alexander Staubo alex@mop.no
Tue, 1 Jun 1999 04:32:21 +0200


Martijn Faassen wrote:
[snip]
>Am I doing something wrong, or is this a bug? A related question: is
>there a way to check if a property id (acquired from the folder *or*
>defined locally in the DTML Document) exists or not (and get at its
>contents), from within an external method? hasProperty is not working
>well either...

You can write an external method that uses the Python hasattr() function
to check for the attribute; strangely the _ namespace has a "getattr"
function, but none for checking the existence of an attribute. My own
implementation looks like this:

	def HasAttr(Obj, Attr):
	  return hasattr(Obj, Attr)

This works with Acquisition.

--
Alexander Staubo             http://www.mop.no/~alex/
"It has taken the planet Earth 4.5 billion years to discover it is
4.5 billion years old." --George Wald