[Zope] Propblem with script from Zope book

Jamie greatbks@truevine.net
Fri, 11 Apr 2003 16:57:24 -0400


The script will run now but it just returns ['dummy']

I changed it around to fit my purposes (I am trying to build a DTML
Method that changes the order my Content objects are displayed in. The
objects are sorted by an integer property called SortOrder. So far the
DTML Method returns a value for SortOrder of the object to be moved up,
this is the variable SortNum. Eventually I would like to be able to move
items up or down in the sort order from this method, but am trying to
get it working just moving them up first then I will worry about moving
them down. What I need is this script to find the id of the object with
a SortOrder of SortNum. Then I can determine the objects with
SortOrder's either above or below the one to move and change the
SortOrder of all objects effected by the move.

results=3D['dummy']
for object in context.objectValues('Content'):
 if object.propertysheets.userProperties.getProperty('SortOrder') =3D=3D
SortNum
    results.append(object)
return results

Any ideas?

Jamie White
Jamie@brobus.net

-----Original Message-----
From: Geir B=E6kholt [mailto:lists@elvix.com]=20
Sent: Friday, April 11, 2003 11:45 AM
To: Jamie on The Zope Mailinglist
Cc: Zope mailinglist
Subject: Re: [Zope] Propblem with script from Zope book

On  Fri, 11 Apr 2003 11:20:53 -0400 GMT (..17:20 where i live(GMT+1) )
Jamie asked the Zope mailinglist about the following:

J> I'm having problems running this example script from the Zope Book,
J> Advanced Scripting Chapter, p. 183

J> """
J> Returns all sub-objects that have a given status
J> property.
J> """
J> results=3D[]
J> for object in context.objectValues():
J>     if object.getProperty('status') =3D=3D status:
J>         results.append(object)
J> return results

J> It seems to be starting an endless loop or something, the browser can
J> sit for a half an hour and still not change.

Might just be that your loops finds no objects for which status =3D=3D
status.. When a script returns false (0, None, empty list etc.. ) the
browser does not get any visible response...

try changing this one line:
results=3D[]
to
results=3D["dummy"]
and see if it still hangs....

:)


--
Geir B=E6kholt