how to use sequence-end from python script?
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']? thanks a lot -Kevin __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
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
for item in sequence: if item == sequence[0]: print "sequence-start" if item == sequence[-1]: print "sequence-end" That's the way to do it in Python. Alternativly: for c in range(len(sequence)): item = sequence[c] if item == sequence[0]: print "sequence-start" print "sequence-index:", c print "sequence-number", c+1 if c%2: print "sequence-odd" else: print "sequence-even" if item == sequence[-1]: print "sequence-end" Bare in mind that there are still no variables here. Just print statements. ----- Original Message ----- From: "ender" <kthangavelu@earthlink.net> To: "Kevin L" <kevinsl@yahoo.com>; <zope@zope.org> Sent: Sunday, July 08, 2001 7:04 PM Subject: Re: [Zope] how to use sequence-end from python script?
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
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
ender -
Kevin L -
Peter Bengtsson