Re: [Zope] Arrg! dtml-in can't handle lists of pairs!
Cary O'Brien writes: > > "Cary O'Brien" <[EMAIL PROTECTED]> writes: > > > It seems as if dtml-in handles lists of pairs specially. > > It does, and it is documented. > > Where? I even looked through the code in DT_In.py and couldn't > figure out where it handled this special case. This seems > to me like a pretty big gotcha. >From Document Template User Guide: dtml_in -> variables defined sequence-key The key associated with the element in an items sequence. An items sequence is a sequence of value pairs that represent a mapping from a key to a value. Dieter ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] Arrg! dtml-in can't handle lists of pairs!
> "Cary O'Brien" <[EMAIL PROTECTED]> writes: > > It seems as if dtml-in handles lists of pairs specially. > It does, and it is documented. Where? I even looked through the code in DT_In.py and couldn't figure out where it handled this special case. This seems to me like a pretty big gotcha. I did find out that a list of two items was not handled the same way as a tuple of two items. Unfortunately I couldn't figure out how to invoke list(). > > For pairs, the first component becomes "sequence-key" and > the second "sequence-item". > > > Not a good thing. Can I supress this behavior? > Not that I know. Well, the only solution I came up with was to iterate with an index over the size of the thing. -- cary ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] Arrg! dtml-in can't handle lists of pairs!
"Cary O'Brien" <[EMAIL PROTECTED]> writes: > It seems as if dtml-in handles lists of pairs specially. It does, and it is documented. For pairs, the first component becomes "sequence-key" and the second "sequence-item". > Not a good thing. Can I supress this behavior? Not that I know. Dieter ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] Arrg! dtml-in can't handle lists of pairs!
I have confirmed that this is strange behavior can be reproduced on 2.1.6 -- why I don't know. A work around may be to convert your tuples to lists (easy to do in python) sample working code: Iterate over 3.tuples Iterate Over 2-tuples Why can't I do this! Iterate Over 1-tuples On Sat, 01 Jul 2000, Cary O'Brien wrote: > Ok. I get a list of rows from a database query. I want > to iterate over the rows. If there are 3 or more > columns in the table, everythin is fine. If there are 2 > columns, it doesn't work. > > It seems as if dtml-in handles lists of pairs specially. > Not a good thing. Can I supress this behavior? > > Here is an example of this: > > --- > > Iterate over 3.tuples > > > > > > > > > > Iterate Over 2-tuples > > > > > > > > > > Why can't I do this! > > > > Iterate Over 1-tuples > > > > > > > > > > > --- > > -- cary > > ___ > Zope maillist - [EMAIL PROTECTED] > 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 ) ___ Zope maillist - [EMAIL PROTECTED] 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 )