[Zope] objectValues return value

Tino Wildenhain tino@wildenhain.de
Thu, 05 Dec 2002 01:31:25 +0100


Hi David,

--On Mittwoch, 4. Dezember 2002 10:17 -0700 David Bear <David.Bear@asu.edu> 
wrote:

> 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?

the method is designed to return a list, so if no objects
are in - the list is empty. An empty list is not None!

return [zpt.title_or_id() for zpt in context.objectValues('Page Template')] 
or 'none'

would do the job.
But I dont think its very usefull to return different datatype (list vs. 
string)
on different conditions. What do you want to do with the
result after that?

Regards
Tino


># 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
>
>
> --
>
> David Bear
> College of Public Programs/ASU
> Mail Code 0803
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )