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

Max M maxmcorp@worldonline.dk
Mon, 17 Sep 2001 08:57:05 +0200


> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
> Trevor Toenjes

> My first attempt at a python script and the back-up DTMLMethod dont work.
> What am I doing wrong?

> ###DTMLMethod 'objectIds' /in zClass/methods
>
> <dtml-in expr="objectValues('anotherZclass')">
>   <dtml-var id>
> </dtml-in>
> </dtml-with>
> 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?

Why don't you just use the built in objectIds ???

<dtml-with folder_of_anotherZclass>
    <dtml-in "objectIds('anotherZclass')">
        <dtml-var sequence-index>
    </dtml-in>
</dtml-with>

> 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

for id in context.folder_of_anotherZclass.objectValues('anotherZclass'):
    myList.append(id)
    return myList

"context" being "The current document or folder" you are in.

But then again this method is not nessecary.

For more info about the built in methods try the zope Book unde API, and se
the objectManager class.

regards Max