[Zope] Propblem with script from Zope book
Jamie
greatbks@truevine.net
Fri, 11 Apr 2003 17:26:40 -0400
J> I changed it around to fit my purposes (I am trying to build a DTML
J> Method that changes the order my Content objects are displayed in.
The
J> objects are sorted by an integer property called SortOrder. So far
the
J> DTML Method returns a value for SortOrder of the object to be moved
up,
J> this is the variable SortNum. Eventually I would like to be able to
move
J> items up or down in the sort order from this method, but am trying to
J> get it working just moving them up first then I will worry about
moving
J> them down. What I need is this script to find the id of the object
with
J> a SortOrder of SortNum. Then I can determine the objects with
J> SortOrder's either above or below the one to move and change the
J> SortOrder of all objects effected by the move.
You want to interate through a sequence of 'Content' objects and
return the first one you hit that has SortOrder equal to SortNum ?
(You seem to know that one exists, and that there is only one..)
it doesn't do it, it returns no matching object found. Though I know
that there is a Content object with the value I used for SortNum
will this (untested) do the job ?
for object in context.objectValues('Content'):
if object.SortOrder =3D=3D SortNum:
return object
return "no matching object found"
--
Geir B=E6kholt