[Zope] (newbie)-Calling in Multiple Selection from a Z-Class
Small Business Services
toolkit at magma.ca
Wed Dec 17 18:04:06 EST 2003
You may need something more sophisticated than ZClasses. Have a look a ZCatalog in the ZopeBook. We use them a lot with great success.
Regarding the 'Error Value: globla name Animal is not defined...
Go to where your ZClass is defined (in the ZMI under Control_Panel/Products/YourProductName) and click on your animal zclass. Then click on the 'Basic' tab. The entry under 'Meta Type' is what objectValues will be looking for (make sure spelling and case match).
Jonathan
----- Original Message -----
From: Ben
To: Small Business Services ; zope at zope.org
Sent: December 17, 2003 5:51 PM
Subject: Re: [Zope] (newbie)-Calling in Multiple Selection from a Z-Class
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/20031217/08d2ebe6/attachment.html
More information about the Zope
mailing list