[Zope] how-to: dynamically create a list for the Value of a zClass multiple-selection Type?

Trevor Toenjes zope@toenjes.com
Sun, 16 Sep 2001 21:27:50 -0400


My first attempt at a python script and the back-up DTMLMethod dont work.
What am I doing wrong?
Is there a cross-reference guide to learn Python scripts from a Zope
perspective? (the learn Python books I have yet to immerse into are not in a
Zope context.)

> I recommend to write a Python script which returns
> the result of calling "objectIds" with appropriate variables.
> Use the script's id as value for your selection property.

I have tried this by placing the 'objectIds' in the Value field for
/multiple selection/propertysheets/zClass.

I get this error:
Error Type: InError
Error Value: Strings are not allowed as input to the in tag.

###DTMLMethod 'objectIds' /in zClass/methods
<dtml-with folder_of_anotherZclass>
<dtml-in expr="objectValues('anotherZclass')">
  <dtml-var id>
</dtml-in>
</dtml-with>

Q's:
This works fine when rendering from a folder not in the zclass! why not a
zclass? How do I convert to a list?
Am I placing 'objectIds' in the wrong space?



Python script

Here is my attempt to convert this to a python script.
What is the Python script equivalent to "dtml-with"?
Error Type: NameError
Error Value: global name 'folder_of_anotherZclass' is not defined

###Python script 'objectIds' /in zClass/methods
myList=[]
for id in folder_of_anotherZclass.objectValues('anotherZclass'):
    myList.append(id)
return myList

Thank you for the guidance,
-Trevor