[Zope] Strings, Names and dtml-var

Ender kthangavelu@earthlink.net
Sat, 21 Oct 2000 09:08:12 -0700


swallace@trilobyte.net wrote:

tested

<dtml-with "_.getattr(Colors, color_source)">
<dtml-var color1>
</dtml-with>


> 
> Ok, Being fairly new at Zope, I am really confused, I think I have
> looked through all the FAQs, How to's, examples, and what ever, but
> I still can not get the right combination to get this to work (many
> combinations tried :-)...). The basic intent is to easily change a
> property "color_source" in a directory that will cause the "color1"
> property to be looked up from a different directory. The directory
> name "default" could be one of many that holds different color
> themes. Thanks in advance.
> ***************************Code
> This does not work: get_color method
> <dtml-let myname="'Colors.'+color_source+'.color1'">
>    <dtml-var expr="_[myname]">
> </dtml-let>
> This works:
> <dtml-var "Colors.default.color1"> which renders #FFFFFF
> ***************************Key
> get_color = a method, /Business/Base/get_color
> color_selection = a property in the current directory containing
> the string "default" without quotes
> Colors = a folder, /Business/Colors
> default = a folder, /Business/Colors/default
> color1 = is a property under default containing the string
> "#FFFFFF" without quotes
> Zope = 2.2.2
> OS = Win98
> ***************************Error Message
> Error Type: KeyError
> Error Value: Colors.default.color1
> 
> Troubleshooting Suggestions
> This resource may be trying to reference a nonexistent object
> or variable Colors.default.color1.
> The URL may be incorrect.
> The parameters passed to this resource may be incorrect.
> A resource that this resource relies on may be encountering
> an error.
> 
> _______________________________________________
> 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 )