At 09:36 AM 2/1/99 +0200, you wrote:
Timothy Grant <tjg@avalongroup.net> writes:
I think <!--#with _.namespace(tempvar=tempval) --> use tempvar here ... <!--#/with--> should do it, although I haven't tried it yet.
I'll give this a shot, I'm somewhat concerned as tempvar will be assigned inside a <!--#in--> construct and used outside the loop.
_[Category] should give you indirect access to the variable whose name is the value of Category. Note the lack of quotes around Category (as opposed to your code above).
Tell me if this doesn't work for you (and I'll look more into it).
This unfortunately does not work at all, when I use it I get the Zope Error message saying Zope is unavailable. Thanks for your willing assistance! -- Stand Fast, tjg. =================================== Timothy J. Grant tjg@avalongroup.net Avalon Technology Group www.avalongroup.net (503) 246-3630 voice (503) 246-3124 fax This message may be digitally signed with PGP. A PGP signature guarantees that this message really did come from me. For more information regarding digital signatures and encryption, please contact me.
At 11:14 AM 2/1/99 -0800, Timothy Grant wrote:
At 09:36 AM 2/1/99 +0200, you wrote:
Timothy Grant <tjg@avalongroup.net> writes:
I think <!--#with _.namespace(tempvar=tempval) --> use tempvar here ... <!--#/with--> should do it, although I haven't tried it yet.
I'll give this a shot, I'm somewhat concerned as tempvar will be assigned inside a <!--#in--> construct and used outside the loop.
The above construct won't work, since "with" only applies to its lexical nesting scope. Use <!--#call "REQUEST.set('tempvar',tempval)"--> instead.
_[Category] should give you indirect access to the variable whose name is the value of Category. Note the lack of quotes around Category (as opposed to your code above).
Tell me if this doesn't work for you (and I'll look more into it).
This unfortunately does not work at all, when I use it I get the Zope Error message saying Zope is unavailable.
View the HTML source of the error message to get more details on what is happening.
At 05:02 PM 2/1/99 -0500, you wrote:
At 11:14 AM 2/1/99 -0800, Timothy Grant wrote:
At 09:36 AM 2/1/99 +0200, you wrote:
The above construct won't work, since "with" only applies to its lexical nesting scope. Use <!--#call "REQUEST.set('tempvar',tempval)"--> instead.
Thanks Phillip! This was the missing piece. It works beautifully now.
_[Category] should give you indirect access to the variable whose name is the value of Category. Note the lack of quotes around Category (as opposed to your code above).
Tell me if this doesn't work for you (and I'll look more into it).
This unfortunately does not work at all, when I use it I get the Zope Error message saying Zope is unavailable.
View the HTML source of the error message to get more details on what is happening.
Wow, I wish I had known you could do this a while ago! It would be nice if there were a developer mode where this information comes up by default in the message. Thanks for your kind assistance! Here's the traceback: <!-- Error type: Error value: _[Category] --> </BODY></HTML> <!-- Traceback (innermost last): File /home/brian/temp/build/tmp_build/Zope-1.9.0-linux2-x86/lib/python/ZPublisher /Publish.py, line 879, in publish_module File /home/brian/temp/build/tmp_build/Zope-1.9.0-linux2-x86/lib/python/ZPublisher /Publish.py, line 595, in publish (Info: /Pricing/index_html) File /home/brian/temp/build/tmp_build/Zope-1.9.0-linux2-x86/lib/python/OFS/Docume nt.py, line 181, in __call__ (Object: index_html) File /home/brian/temp/build/tmp_build/Zope-1.9.0-linux2-x86/lib/python/OFS/Docume nt.py, line 177, in __call__ (Object: index_html) File /home/brian/temp/build/tmp_build/Zope-1.9.0-linux2-x86/lib/python/DocumentTe mplate/DT_String.py, line 514, in __call__ (Object: index_html) File /home/brian/temp/build/tmp_build/Zope-1.9.0-linux2-x86/lib/python/DocumentTe mplate/DT_In.py, line 687, in renderwob (Object: PriceCategories) KeyError: (see above) -- Stand Fast, tjg. =================================== Timothy J. Grant tjg@avalongroup.net Avalon Technology Group www.avalongroup.net (503) 246-3630 voice (503) 246-3124 fax This message may be digitally signed with PGP. A PGP signature guarantees that this message really did come from me. For more information regarding digital signatures and encryption, please contact me.
At 03:19 PM 2/1/99 -0800, Timothy Grant wrote:
Here's the traceback:
<!-- Error type: Error value: _[Category] --> ... KeyError: (see above)
My guess is you used <!--#var _[Category]--> when you should've used <!--#var "_[Category]"-->. The latter is an expression, looking up the variable whose name is in variable Category, while the former looks for a variable *whose name* is "_[Category]", and doesn't exist, therefore causing a KeyError.
At 08:52 AM 2/2/99 -0500, you wrote:
At 03:19 PM 2/1/99 -0800, Timothy Grant wrote:
KeyError: (see above)
My guess is you used <!--#var _[Category]--> when you should've used <!--#var "_[Category]"-->. The latter is an expression, looking up the variable whose name is in variable Category, while the former looks for a variable *whose name* is "_[Category]", and doesn't exist, therefore causing a KeyError.
Thanks Phillip. This indeed got me closer, but I'm still not quite there yet. I'm building system that has dynamically generated buttons on it. The name of each input is based on the contents of a TinyTable thusly: <select name="<!--#var Category-->" size=1> <!--#in "PriceTable(PriceGroup=_['Category'])"--> <option><!--#var Description--> <!--#call "REQUEST.set('cost',Cost)"--> <!--#/in--> This works beautifully, and generates HTML that looks like: <select name="Processor" size=1> <option>AMDK6 350 <option>Celeron 333 <option>PentiumII 450 </select> So now, I want to get at the value of the variable named "Processor," but I don't "know" that the name of the variable is "Processor" hence the indirection. Using your chunk of code above, my traceback reflects the following change in the correct direction but not quite there. <!-- Error type: Error value: Processor --> I'm guessing that I need another level of indirection and I'm not quite sure how to get there. Thanks. -- Stand Fast, tjg. =================================== Timothy J. Grant tjg@avalongroup.net Avalon Technology Group www.avalongroup.net (503) 246-3630 voice (503) 246-3124 fax This message may be digitally signed with PGP. A PGP signature guarantees that this message really did come from me. For more information regarding digital signatures and encryption, please contact me.
So now, I want to get at the value of the variable named "Processor," but I don't "know" that the name of the variable is "Processor" hence the indirection. Using your chunk of code above, my traceback reflects the following change in the correct direction but not quite there.
Maybe you can set another variable in REQUEST to the name of the form variable: REQUEST.set('form_var_name',_['Category']) in the case you described it will hold the string 'Processor'. You can then access its contents by: _.getitem(form_var_name) I hope ;-) Then again I have not followed the thread so my apologies if my suggestion is out of context. Pavlos
participants (3)
-
Pavlos Christoforou -
Phillip J. Eby -
Timothy Grant