[Zope] batching/looping to find next item in python-scripts

Trevor Toenjes zope@toenjes.com
Wed, 19 Sep 2001 16:58:23 -0400


I am trying to move all logic from DTML (not that I get it yet.  :)
I am now trying to generate the object that precedes the current
object(zClass) in a folder.  called by ...<a href"<dtml-var getPrevious>">
Previous </a>

What am I doing wrong here?...I realize I am missing some fundamentals.

# getPrevious Script (Python)
#
# determine the position of the current object
y=0
for o in context.objectIds():
    y=y+1
    if sequence-item
        currentPosition=y

## loop to the previousItem and get ID
for o in context.objectIds():
    if sequence-item == currentPosition-1
        previousObject=sequence-item.id

return previousObject


This is the DTML that doesnt quite work, that I am replacing.
<dtml-in "objectIds()" start=qs size=1 orphan=0>
    <dtml-var sequence-item>
    <a href="&dtml-URL;?qs=<dtml-var
"_.int(_['sequence-index'])+1">">Next</a>
</dtml-in>

...likewise I will create a getNext.

TIA for the lesson,
-Trevor Toenjes