Re: [Zope] Help with simple dtml-if compare

2000-05-26 Thread Curtis Maloney

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

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Help with simple dtml-if compare

2000-05-26 Thread Patrick J.M. Keane


Thanks for the quick fix.  I really thought it was time to go to bed.  Now that
it makes sense, I have to rethink whether I have enough evidence that I'm
tired.  :-)

pk



___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Help with simple dtml-if compare

2000-05-26 Thread Graham Chiu

In article [EMAIL PROTECTED], Patrick J.M. Keane
[EMAIL PROTECTED] writes
dtml-if "id == 'index_html'"

dtml-if "_['id']=='index_html'" 

as discussed yesterday in this list!

-- 
Regards,  Graham Chiu
gchiuatcompkarori.co.nz
http://www.compkarori.co.nz/index.php
Powered by Interbase and Zope

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Help with simple dtml-if compare

2000-05-26 Thread Rik Hoekstra

snip

 
 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.


Um, except that id is not always a method ;-(, hence the _['id'] idiom
(see discussion earlier this week)

Rik

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )