[Zope] DTML Document Properties strangeness

Brian Lloyd Brian@digicool.com
Tue, 1 Jun 1999 09:54:51 -0400


> Hi there,
> 
> I've posted about this before but didn't get a satisfactory 
> answer yet.
> I'm using an external method with a DTML Document, and inside that
> external method I want to look at the properties of the DTML 
> Document. I
> keep having problems with it so I reduced the problem to the 
> following.
> I have this external method:
> 
> def getPropertyIds(self):
>     return self.propertyIds()
> 
> Inside a DTML Document I have this:
> 
> <!--#var standard_html_header-->
> <p><!--#var "getPropertyIds()"--></p>
> <p><!--#var "propertyIds()"--></p>
> <!--#var standard_html_footer-->
> 
> I would expect these two to give the same list of property ids, but
> instead the external method returns the list of properties in the
> *folder*, not in the document (like <!--#var "propertyIds()"--> does).
> 
> 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...

Martijn,

Remember that DTML Documents behave a little differently than
DTML Methods, External Methods and other "method"-like objects.

The "self" in your "getPropertyIds" external method is going to be
the _folder_, not the DTML Document. In a DTML Document, the implicit
"self" namespace is the DTMLDocument itself, but this does extend
to any method-like objects called from the DTML Document - they
will continue to act as methods of their containers (and _not_ like
methods of the DTML Document).

One thing you could do to accomplish what you are trying to do 
is to extend your getPropertyIds() method to accept an argument:

def getPropertyIds(self, obj):
    return obj.propertyIds()

<!--#var "getPropertyIds(this())"-->


Hope this helps!

Brian Lloyd        brian@digicool.com
Software Engineer  540.371.6909              
Digital Creations  http://www.digicool.com