[Zope] What does "this()" return?

Hung Jung Lu hungjunglu@hotmail.com
Tue, 04 Jan 2000 19:54:33 PST


Hi,

The "this()" method returns the object itself. Or at least that's what it's 
supposed to do.

But if I have a folder named "myFolder" inside which I have a DTML method 
named "myMethod" consisting of the following lines:

  <dtml-if "this() == myFolder">
    Hallo
  <dtml-else>
    Bye-Bye
  </dtml-if>

The result is always Bye-Bye, when viewing myMethod.

So the "this()" method is tricky.

In the same league is the "id()" method, which is also tricky. And often I 
have to use "_['id']" to get what I want.

The following works:

  <dtml-if "this().id == myFolder.id">
    Hallo
  <dtml-else>
    Bye-Bye
  </dtml-if>

However, this does not work:

  <dtml-if "this.id == myFolder.id">
    Hallo
  <dtml-else>
    Bye-Bye
  </dtml-if>

All these weird behaviors of "this()" and "id()" are sending my head 
spinning. When to use parenthesis, when not to use parenthesis, when to use 
"_['id']", when you can use ".", when you can't use ".", argghhhh....

Is there any doc on "this()" or "id()"?

Aside from the "How-to..." docs, shouldn't we start compiling "Zope 
Pitfalls" or "Zope Gotchas" doc series? Sometimes learning a new software is 
not so much what you know to do, but what you know NOT TO DO.

Also, is there any documentation on calling DTML methods with arguments? I 
know you can do it with "myMethod(_.None,  _, arg1=val1, arg2=val2, ...)", 
but I'd like to know what the role of _.None is. (I know _ is the 
namespace...), that is, if I replace it with something like 
"myMethod(coolDude, _, ...)" what sort of catastrophe might happen. :)

regards,

Hung Jung

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com