[Zope] Help with simple dtml-if compare

Curtis Maloney curtis@umd.com.au
Fri, 26 May 2000 17:25:44 +1000


On Fri, 26 May 2000, Patrick J.M. Keane wrote:
> Bug?  Or am I missing something.
>
most likely you're missing something. (o8

> Create a default document called 'index_html', with these contents:
>
> <dtml-var standard_html_header>
> <dtml-if "id == 'index_html'">
> index_html == <dtml-var id>
> <dtml-else>
> index_html != <dtml-var id>
> </dtml-if>
> <dtml-var standard_html_footer>
>
> Basically, we're comparing the document id -- "index_html" to the string
> "index_html".

yep.. well... this is quite a common question, all up.  It comes from people 
using shorthand, but not relaising it.  sometimes i wonder if this feature 
should be removed.

the line:

<dtml-if "id == 'index_html'">

is actually shorthand for:

<dtml-if expr="id == 'index_html'" >

which means your expression is handled as a python expression, not a DTML 
one.  In which case, you are comparing a function object (id)  with a string 
object ('index_html').

the simple fix is, of course, to 'call' the function....

<dtml-if "id() == 'index_html'">

should do what you're expecting.

> Thanks
> PK
>

</waffle>

-- 
Have a better one,
	Curtis.

<dtml-var standard_work_disclaimer>