[Zope] string crisis....

Martijn Pieters mj@antraciet.nl
Wed, 08 Sep 1999 17:09:58 +0200


At 16:38 08/09/99 , Arnaud Lecat wrote:
>id is ok for me... it contains the good string
>
>A simple display test for
>*<dtml-var mydocid>*<dtml-var id>*
>
>gives me
>*design*design*
>
>And <dtml-if "mydocid==id">blah blah</dtml-if> is not true !!! What's
>happening ?
>
>(* is for a purpose of display to see if there were some unwanted char in
>front or behind the string)

That is because <dtml-var id> will call the method id if id is a method. 
This is called a namespace lookup. So comparing anything to the method 
object 'id', will always evaluate to false.

Now, you could simulate the behaviour with _['id'], which will do a 
namespace lookup for the object called 'id', wether it is a string or a 
method, and will always, in this case, return a string.

You could do <dtml-if "mydocid==id()">, but then you'd make the test throw 
an exception for those objects where id _is_ a string. Using _['id'] will 
work in both cases: <dtml-if "mydocid==_['id']">

--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-7502100 Fax: +31-35-7502111
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------