[Zope] objectValues return value
Brian Lloyd
brian@zope.com
Wed, 4 Dec 2002 13:18:26 -0500
> I wrote a script the returns a list object of all title_or_id
> values of objects in a folder. The problem is when there are no
> objects in the folder. The script should return a list
> contianing the string 'none'.. but doesn't. In fact, the script
> seems to either hang or have no return value...
>
> Any pointers?
>
> # returns a python list contained the title of the page templates
> in this folder
> list = context.objectValues('Page Template')
> if list == None:
> return ['none']
> newlist = []
> for zpt in list:
> newlist.append(zpt.title_or_id())
> return newlist
The objectValues method should return an empty list if the
collection is empty, not None. Try:
list = context.objectValues('Page Template')
if not list:
return ['none']