[Zope] (newbie)-Calling in Multiple Selection from a Z-Class

Ben beninisrael at hotmail.com
Wed Dec 17 17:51:18 EST 2003



Thanks for you prompt reply.

I tried calling in the meta type directly, but get:
Error Value: global name 'Animal' is not defined
which is why I am using a slight work-around.
For the purpose of this z-class, it is necessary for me to use a multiple selection list, which I believe will not work properly with the hasProperty function . Is there any other way to do it? Possibly iterating through the number of values which each instance holds for the multiple list? Am a bit stumped on the syntax though!

Thanks,

Ben
  ----- Original Message ----- 
  From: Small Business Services 
  To: Ben ; zope at zope.org 
  Sent: Thursday, December 18, 2003 12:34 AM
  Subject: Re: [Zope] (newbie)-Calling in Multiple Selection from a Z-Class


  If you used property fields to implement the 'hooves' (and other) attributes, then you can use the hasProperty function to test if a given instance has 'hooves'

  eg.  <dtml-if "animalinstance.hasProperty('hooves')">

  Look in the API section of the Zope Book for more info.

  P.S.   You can also check for meta types directly:

     <dtml-in "objectValues('Animal')">


  HTH

  Jonathan


    ----- Original Message ----- 
    From: Ben 
    To: zope at zope.org 
    Sent: December 17, 2003 5:13 PM
    Subject: [Zope] (newbie)-Calling in Multiple Selection from a Z-Class


    # I have a Z-Class called animals with a multiple selection for animal_catagories
    # I call in each member of the Z-class:

    <dtml-with AnimalDirectory>
      <dtml-in expr="objectValues()">
       <dtml-if "meta_type==' Animal">

    # For testing:

    <dtml-var id> has <dtml-var animal_catagories>

    # Which gives me "Horse is ['hooved','brown','horsey'] as these are the values that I have given to the horse instance
    # I then have:

            <dtml-if expr="REQUEST['hooved'] == _['animal_categories'][0]">
                    <dtml-var id> is a  <dtml-var hooved> animal
                           </dtml-if>
     
    # Which gives me  Horse is a hooved animal. Which is great!
    # Except this is only checking for the first value. If hooved were the second value chosen in the multiple select list, then this would not show. This is obvious because of the [0]
    # What I am trying to do is to compare hooved with each of the animal categories to see if it has been chosen. If I use a  <dtml-in animal_catagories> with or without ''s, then it tells me that I can't call in a string. 
    # Could anyone please help me, or point me in the right direction? 

    Thanks,

    Ben



----------------------------------------------------------------------------


    _______________________________________________
    Zope maillist  -  Zope at zope.org
    http://mail.zope.org/mailman/listinfo/zope
    **   No cross posts or HTML encoding!  **
    (Related lists - 
     http://mail.zope.org/mailman/listinfo/zope-announce
     http://mail.zope.org/mailman/listinfo/zope-dev )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20031218/7737119d/attachment.html


More information about the Zope mailing list