[Zope-dev] Re: [Zope] Question about dtml-in
Sean McGrath writes: ... "dtml-in" treats sequences of two element tuples specially ... You are right. This is to support the frequent case of iterating over item sequences. There should be a "dtml-in" argument to switch off this special treatment. If I had your problem, I would go for such a solution (extending "dtml-in"). It should be easier than to work around the special treatment in DTML and it would help the Zope community as a whole. If you do not want to go this way, I would suggest to put a feature request into the Collector. Dieter ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope] Question about dtml-in
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 html. Result object api. /lib/python/Shared/DC/ZRDB/Result.py ___ 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] Question about dtml-in
Sean McGrath writes: ... "dtml-in" treats sequences of two element tuples specially ... You are right. This is to support the frequent case of iterating over item sequences. There should be a "dtml-in" argument to switch off this special treatment. If I had your problem, I would go for such a solution (extending "dtml-in"). It should be easier than to work around the special treatment in DTML and it would help the Zope community as a whole. If you do not want to go this way, I would suggest to put a feature request into the Collector. 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] Question about dtml-in sorting
"Patrick J.M. Keane" wrote: Does sort only sort in one direction? I am looking to sort news items so that the newest items are on top, and when sorting on a date field, I get the opposite behaviour. Any easy way to reverse the sort order? Yes, by adding reverse to the sort tag ;-) dtml-in sortablelist sort=sorting_variable reverse Rik ___ 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] Question about dtml-in sorting
Patrick J.M. Keane writes: Does sort only sort in one direction? I am looking to sort news items so that the newest items are on top, and when sorting on a date field, I get the opposite behaviour. Any easy way to reverse the sort order? Thanks pk dtml-in MyItems sort=whatever reverse Jason Spisak CIO HireTechs.com 6151 West Century Boulevard Suite 900 Los Angeles, CA 90045 P. 310.665.3444 F. 310.665.3544 Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats. ___ 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] Question about dtml-in sorting
Patrick J.M. Keane wrote: I get the opposite behaviour. Any easy way to reverse the sort order? Well, I found there _is_ a reverse attribute to the dtml-in tag, but it's not documented in my version (2.1.0, 1999/12/17) of the DTML Reference. It works. Cheers, Nils ___ 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 )