Hi all, One of the very first questions I had regarding Zope was how to do variable indirection. I wanted to reference a variable that was actually named in another variable. That one was quickly taken care of by this list, now I have another redirection question: I have a text box that is named based such liked this <input type="text" name="<dtml-var Category>_qty" size="5" value=""> This works beautifully and I end up with a bunch of variables named things like "Config_qty", "Harddrive_qty", etc. I now need to access these variables in the next form. The name of the variable is contained in "Category" <dtml-var Category> gives me the part of the variable name before the underscore. I tried to get <dtml-var expr="<dtml-var Category> + '_qty'"> to work, but that generates syntax errors. Any clues to this would be greatly appreciated. Thanks. -- Stand Fast, tjg. ================================================================ Timothy Grant tjg@exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Chief Technology Officer (503) 246-3630 Avalon Technology Group (503) 246-3124
>>>>>> Exceptional Minds, Innovative Products <<<<<<<<<<<<
On Sun, 22 Aug 1999, Timothy Grant wrote:
<input type="text" name="<dtml-var Category>_qty" size="5" value="">
This works beautifully and I end up with a bunch of variables named things like "Config_qty", "Harddrive_qty", etc.
I now need to access these variables in the next form. The name of the variable is contained in "Category"
<dtml-var Category> gives me the part of the variable name before the underscore.
I tried to get <dtml-var expr="<dtml-var Category> + '_qty'"> to work, <dtml-var "_[Category+'_qty']">
Andreas -- Andreas Kostyrka | andreas@mtg.co.at phone: +43/1/7070750 | phone: +43/676/4091256 MTG Handelsges.m.b.H. | fax: +43/1/7065299 Raiffeisenstr. 16/9 | 2320 Zwoelfaxing AUSTRIA
At 07:45 23/08/99 , Timothy Grant wrote:
<dtml-var Category> gives me the part of the variable name before the underscore.
I tried to get <dtml-var expr="<dtml-var Category> + '_qty'"> to work, but that generates syntax errors.
Above line is a nested DTML tag, which doesn't work. You have to ask the namespace for the variable with the name that consists of the string contained in the variable Category, concatenated to the string literal '_qty': <dtml-var "_[Catagory + '_qty']"> _[...] is the namespace lookup, and you look up variable named by the string made up from Category + '_qty'. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
On a related note: Is there a way to get indirection on the field name provided to a <dtml-in Folder sort="SomeVariableFieldIdHere"> ? I've tried beaucoup variations without success. I've looked at the python, and I'm not sure that the trick would be. Is it just impossible? If it is impossible, should I be moving to ZClasses, and migrate my dtml code into python with DTML templates instead of just vanilla dtml? Any help appreciated. Thanks, = Joe = Martijn Pieters wrote:
At 07:45 23/08/99 , Timothy Grant wrote:
<dtml-var Category> gives me the part of the variable name before the underscore.
I tried to get <dtml-var expr="<dtml-var Category> + '_qty'"> to work, but that generates syntax errors.
Above line is a nested DTML tag, which doesn't work.
You have to ask the namespace for the variable with the name that consists of the string contained in the variable Category, concatenated to the string literal '_qty':
<dtml-var "_[Catagory + '_qty']">
_[...] is the namespace lookup, and you look up variable named by the string made up from Category + '_qty'.
-- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
At 17:19 23/08/99 , Joe Grace wrote:
On a related note:
Is there a way to get indirection on the field name provided to a
<dtml-in Folder sort="SomeVariableFieldIdHere">
? I've tried beaucoup variations without success. I've looked at the python, and I'm not sure that the trick would be. Is it just impossible?
If it is impossible, should I be moving to ZClasses, and migrate my dtml code into python with DTML templates instead of just vanilla dtml?
That is indeed impossible right now, as sort only takes a name, not an expression. You could try and extend the in tag to support a sort_expr attribute. I believe DC was thinking of adding something like that. Or you could indeed switch to ZClasses. Another solution might be Zieve, a sorting product. It can be found in the contributed products area on the Zope website: http://www.zope.org/Download/Contrib/ This the second beta. The documents still talk about creating a ZClass which subclasses the Zieve in places, but this is not necessary any longer. Just create an instance of it somewhere, and it will do dynamic sorting for you, with per user sorting preferences, stored in a cookie. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
participants (4)
-
Andreas Kostyrka -
Joe Grace -
Martijn Pieters -
Timothy Grant