dtml-in mapping, and sessions
Hi, I'm trying to output reports based on the result of a database query contained in a session variable. It goes <dtml-in loopname mapping> <dtml-var this><dtml-var that><dtml-var the_other><br> <dtml-if "sequence-item > size"> If at the end of the current sequence size, summarise all further results: <dtml-let other-this="other-this + 1" other-that="other-that + 1" other-theother="other-the_other +1"
<dtml-if sequence-end> <dtml-var other-this> <dtml-var other-that> <dtml-var other-theother> </dtml-if> </dtml-if> </dtml-let> <dtml-in> The problem is that the variable is a session variable: this is I think why anything like "<dtml-var sequence-step-size>" gives a key error. Is there a way to de-map things when working with the sequence? Thanks, Ale -- Alejandro Fernandez Electronic Group Interactive --+34-65-232-8086--
everything inside an expr="" (and "" is a shorthand for expr="") is a pythonic expression, and sequence-item is not a valid variable name in python. see chapter 8, "DTML Namespace Utility Functions" of the zope book Alejandro Fernandez wrote:
Hi,
I'm trying to output reports based on the result of a database query contained in a session variable.
It goes
<dtml-in loopname mapping> <dtml-var this><dtml-var that><dtml-var the_other><br> <dtml-if "sequence-item > size"> If at the end of the current sequence size, summarise all further results:
<dtml-let other-this="other-this + 1" other-that="other-that + 1" other-theother="other-the_other +1"
<dtml-if sequence-end> <dtml-var other-this> <dtml-var other-that> <dtml-var other-theother> </dtml-if> </dtml-if> </dtml-let> <dtml-in>
The problem is that the variable is a session variable: this is I think why anything like "<dtml-var sequence-step-size>" gives a key error. Is there a way to de-map things when working with the sequence?
Thanks,
Ale
Alejandro Fernandez writes:
I'm trying to output reports based on the result of a database query contained in a session variable.
It goes
<dtml-in loopname mapping> <dtml-var this><dtml-var that><dtml-var the_other><br> <dtml-if "sequence-item > size"> Avoid names containing "-" in Python expressions!
Use the "prefix" argument for "dtml-in". See the Zope Book for more information... Dieter
On Mon, 8 Jul 2002 21:11:41 +0200 Dieter Maurer <dieter@handshake.de> wrote:
Alejandro Fernandez writes:
It goes
<dtml-if "sequence-item > size">
Avoid names containing "-" in Python expressions!
Hi, I'm using the names given in the dtml reference appendix of the zope book: under Summary, Batch, and Current Item Variables for the dtml-in loop: next-batches, total-variable, count-variable, sequence-item, sequence-index, etc Is the best way to avoid this <dtml-if "_.getitem('sequence-item' > size)">? Thanks, Ale -- Alejandro Fernandez Electronic Group Interactive --+34-65-232-8086--
[Chris Withers]
"Thomas B. Passin" wrote:
Nope:
<dtml-if "_['sequence-item']">
bzzzzt... wrong.
That will call sequence-item if it is callable, which is often not what you want ;-)
bzzzt...right. The original poster was asking about reserved words used with standard dtml-xx statements, like sequence-item, and it is right for them though not in general (as you said). Cheers, Tom P
Alejandro Fernandez writes:
On Mon, 8 Jul 2002 21:11:41 +0200 Dieter Maurer <dieter@handshake.de> wrote:
Alejandro Fernandez writes:
It goes
<dtml-if "sequence-item > size">
Avoid names containing "-" in Python expressions!
Hi,
I'm using the names given in the dtml reference appendix of the zope book: under Summary, Batch, and Current Item Variables for the dtml-in loop:
next-batches, total-variable, count-variable, sequence-item, sequence-index, etc
Is the best way to avoid this <dtml-if "_.getitem('sequence-item' > size)">? No, the best way is to use the "prefix" attribute of "dtml-in".
Please read the relevant part of the Zope Book.... Dieter
You can tighten it up with the shorthand expression: <dtml-if expr="_['sequence-item'] > size"> If you wish, you could change your dtml-in to use a prefix, which will then force the iterator to use an underscore instead of a dash, giving you: <dtml-in blablah prefix=seq> <dtml-if expr="seq_item > size"> </dtml-if> </dtml-in>
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Alejandro Fernandez Sent: Tuesday, July 09, 2002 2:04 AM To: Dieter Maurer Cc: zope@zope.org Subject: Re: [Zope] dtml-in mapping, and sessions
On Mon, 8 Jul 2002 21:11:41 +0200 Dieter Maurer <dieter@handshake.de> wrote:
Alejandro Fernandez writes:
It goes
<dtml-if "sequence-item > size">
Avoid names containing "-" in Python expressions!
Hi,
I'm using the names given in the dtml reference appendix of the zope book: under Summary, Batch, and Current Item Variables for the dtml-in loop:
next-batches, total-variable, count-variable, sequence-item, sequence-index, etc
Is the best way to avoid this <dtml-if "_.getitem('sequence-item' > size)">?
Thanks,
Ale
-- Alejandro Fernandez Electronic Group Interactive --+34-65-232-8086--
_______________________________________________ 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 (6)
-
Alejandro Fernandez -
Charlie Reiman -
Chris Withers -
Dieter Maurer -
peter sabaini -
Thomas B. Passin