Re: [Zope] Namespace + syntax question
"RC Compaan" <roche@up-front.co.za>
I want to create a list of image thumbnails in a table. On every tenth item i want to start a new row. I thought the "fmod" function is appropriate. I get a syntax error however.
My DTML:
<dtml-in "PARENTS[0].objectItems('Image')"> <dtml-if sequence-start> <table><tr> </dtml-if> <dtml-if "_.fmod(_.['sequence-index'],10)=0">
^ +- BZZT! The "_" object is dictionary-like, and doesn't want a period for key lookup. Use "...( _['sequence-index']..." instead. Aside: I usually end up throwing in a '<dtml-let ...>' to alias those ridiculous "identifiers". What is the status of the patch to alias them automatically (I _still_ can't figure out why they exist)? Tres. -- ========================================================= Tres Seaver tseaver@palladion.com 713-523-6582 Palladion Software http://www.palladion.com
----- Original Message ----- From: Tres Seaver <tseaver@palladion.com>
I usually end up throwing in a '<dtml-let ...>' to alias those ridiculous "identifiers". What is the status of the patch to alias them automatically (I _still_ can't figure out why they exist)?
One thing I find myself often wanting is the ability to do this: <dtml-in expr="arg.bargle[mumble](frotz)" sequence-var=fred> <dtml-in expr="fred.item(3)"> <dtml-var fred/index>: <dtml-var fred/key> <dtml-var sequence-item> </dtml-in> </dtml-in> ...instead of... <dtml-in expr="arg.bargle[mumble](frotz)"> <dtml-let fred_index=sequence-index fred_item=sequence-item fred_key=sequence-key> <dtml-in expr="fred_item(3)"> <dtml-var fred_index>: <dtml-var fred_key> <dtml-var sequence-item> </dtml-in> </dtml-let> </dtml-in> What do you think? Cheers, Evan @ digicool
Evan Simpson wrote:
----- Original Message ----- From: Tres Seaver <tseaver@palladion.com>
I usually end up throwing in a '<dtml-let ...>' to alias those ridiculous "identifiers". What is the status of the patch to alias them automatically (I _still_ can't figure out why they exist)?
One thing I find myself often wanting is the ability to do this:
<dtml-in expr="arg.bargle[mumble](frotz)" sequence-var=fred> <dtml-in expr="fred.item(3)"> <dtml-var fred/index>: <dtml-var fred/key> <dtml-var sequence-item> </dtml-in> </dtml-in>
'<dtml-var fred/index>'??? Are you using some bleading-edge CVS checkout that makes the "/" work like that? Anyway, I think the notion of a "brains"/iterator object makes sense. It would have the properties: name= expr= Semantics ========= =========== ================================================ - fred-item fred.item "Unwrap" the object, like 'sequence-item' - fred-index fred.index Like 'sequence-index' - fred-isStart fred.isStart Like 'sequence-start' (renamed to show predicate) - fred-isEnd fred.isEnd Like 'sequence-end' (renamed to show predicate) and any of the others in the current "sequence-blah" set. The 'sequence-var-nnn' bit could be handled through pure dictionary-style lookup (fred[ 'nnn' ]), or through mangling the identifier (fred-var-nnn). The mapping keyword would set a flag on fred which caused any non-standard getattr to delegate to the wrapped item (or is that getitem?). We could even call the default brains object "sequence", to maintain backward compatibility.
...instead of...
<dtml-in expr="arg.bargle[mumble](frotz)"> <dtml-let fred_index=sequence-index fred_item=sequence-item fred_key=sequence-key> <dtml-in expr="fred_item(3)"> <dtml-var fred_index>: <dtml-var fred_key> <dtml-var sequence-item> </dtml-in> </dtml-let> </dtml-in>
What do you think?
Cheers,
Evan @ digicool
-- ========================================================= Tres Seaver tseaver@palladion.com 713-523-6582 Palladion Software http://www.palladion.com
----- Original Message ----- From: Tres Seaver <tseaver@palladion.com>
'<dtml-var fred/index>'??? Are you using some bleading-edge CVS checkout that makes the "/" work like that?
Actually, its a private hack, but I was effectively including it in the 'proposal' so I wouldn't have to write expr="fred.item" everywhere.
Anyway, I think the notion of a "brains"/iterator object makes sense. It would have the properties:
[snip] Yep, that's what I meant. I hadn't thought about renaming any of the subnames, tho. Cheers, Evan @ digicool
participants (2)
-
Evan Simpson -
Tres Seaver