[Zope] how to use sequence-end from python script?

ender kthangavelu@earthlink.net
Sun, 8 Jul 2001 10:04:45 -0700


On Sunday 08 July 2001 14:58, Kevin L wrote:
>>Hello,
>>
>>I know this is a syntax problem. I just can't find it anywhere
>>in the docs.
>>
>>I'm executing a Z SQL Method from a python script need to test
>>sequence-end. For example
>>
>>for result in context.sqlmethod(params):
>>    # do something
>>    if not 'sequence-end':
>>        # do something here
>>
>>Can anyone tell me how to test for "not sequence-end"? Do I have
>>to use context['sequence-end'] or result['sequence-end']?


the problem is your trying to use batching semantics which are only 
associated with the dtml-in tag. in a python script you have access to the 
entire set of results. if you want to batch in a python script you need to 
devise your own batching scheme. 

for example define a request variable query_start and batch_length

and in your script do (untested)

return context.sqlmethod(params)[query_start:query_start+batch_length]

you'll get back a list of sql brains which you can iterate over like

<dtml-in "mypythonscript(params)">
<dtml-var yoursqlvar1> <dtml-var yoursqlvar2>
</dtml-in>

hth
kapil