Sean McGrath wrote:
> Hello all,
> I have a question about the dtml-in tag. When it is iterating over a
> sequence, and the items in the sequence happen to be tuples containing
> exactly two items, then dtml-in places the first item from the sequence in
> sequence-key, and the second item goes in sequence-item. If the items in
> the sequence are not tuples of two items, then sequence-item contains the
> whole item. For example, if I have:
> <dtml-in "[(1,2),(3,4),(5,6)]">
>         <dtml-var sequence-item>
> </dtml-in>
> then I get 2,4,6 when I view this. The 1, 3 and 5 have been assigned to
> sequence-key. Now, if I change the dtml to be this:
> <dtml-in "[(1,2,3),(3,4,5),(5,6,7)]">
>         <dtml-var sequence-item>
> </dtml-in>
> then I get
> (1,2,3)(3,4,5)(5,6,7)
> which is what I would expect. I think the reason for this behaviour is to
> do with iterating over dictionaries, but I'm not sure. The problem I have
> is this: I have code which retrieves data from a database, and the result
> is a list of tuples, with each tuple corresponding to a record, and each
> item in the tuple corresponding to a field. I don't know in advance how
> many fields will be in the record. I want to iterate over the records and
> fields, wrapping them in a html table. If the database I'm talking to
> happens to return a list of records with two fields, ie a tuple of two
> items, I have to handle this differently than any other case, which makes
> for some ugly code. I haven't been able to find any way to avoid this,
> unless I'm missing something. Any information would be greatly appreciated.
> Regards,

in addition to Dieter Maurer's suggestion of fixing this behavior in
dtml-in, another possibility is to do the work in a web python method,
and directly access the Result object from the query to generate the

Result object api.

Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to