[Zope] Propblem with script from Zope book

Geir Bækholt Geir Bækholt
Fri, 11 Apr 2003 23:33:17 +0200


On  Fri, 11 Apr 2003 17:26:40 -0400 GMT (..23:26 where i live(GMT+2) )
Jamie asked the Zope mailinglist about the following:
  
J> it doesn't do it, it returns no matching object found. Though I know
J> that there is a Content object with the value I used for SortNum

>J> will this (untested) do the job ?

>J> for object in context.objectValues('Content'):
>J>     if object.SortOrder == SortNum:
>J>         return object
>J> return "no matching object found"

Are you sure your SortNums are of the same type ?
"2" and 2 are not equal.. ;)
If you just pass it in a a request parameter, it defaults to a string.

check this one:
http://www.zope.org/Members/Zen/howto/FormVariableTypes

and you can try making yourself some debugging script:

for object in context.objectValues('Content'):
    print "object.SortOrder is %s and SortNum is %s" %(object.SortOrder, SortNum)
return printed

vary as needed to investigate what fails :)

--
Geir Bækholt