On 12/4/05, J Cameron Cooper <[EMAIL PROTECTED]> wrote:
> Christopher Rivard wrote:
> > Hello,
> > I'm am trying to check for the membership of items in a list and think
> > I'm missing something.
> > How is this done in dtml?
> > List allids: [15,16,17,18]
> > Check for multiple items in the list:
> > <dtml-in allids prefix="loop">
> > <dtml-if expr="loop_item == 17">
> > something
> > <dtml-elif expr="loop_item == 17 and loop_item != 18">
> > doesn't work
> > </dtml-if>
> > </dtml-in>
> > The goal is to check for combinations:
> > 17 and not 18
> > 18 only
> > 17 only
> > 17 and 15
> > 18 and 16
> > ...combinations.
> > I don't think that I really want to loop through the list, just want to
> > check membership in the list.
> In Python, you can simply ask::
> 17 in allids
> 18 not in allids
> and so forth as boolean expressions.
He can do this in DTML too.
<dtml-if "17 in allids">
> Just make sure that the elements of the list you're getting are what you
> think they are. If you ask about the integer 17 and the list actually
> has a string "17" they won't match. You can either adjust what you test
> or use something like the 'int' function to "cast".
> Building Websites with Plone
> Zope maillist - Zope@zope.org
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-dev )
Zope maillist - Zope@zope.org
** No cross posts or HTML encoding! **
(Related lists -