On Tue, Oct 30, 2001 at 05:04:21PM -0000, Shane O'Sullivan wrote:
Chris, thanks for your help...I tried your suggestion but it has now returned the error Error Type: NameError Error Value: global name '_' is not defined
If you have time, would you mind explaining what "_" represents? Is this defined in a library that we mightn't have included?
In dtml, the special _ variable is a mapping of the current namespace. So when you do <dtml-let foo=1>, foo now lives inside _ and could be accessed as <dtml-var "_['foo']">. In python scripts, you don't by default have access to the namespace of the calling dtml object. You can get access to it by going to the Bindings tab in the management interface, and set a value for the Namespace binding. You can make it _ or whatever you want, as long as you refer to it by the same name throughout your python script. Chris' example assumes that you have bound Namespace to _. He just forgot to mention that. :) Personally I hate the fact that DTML uses a variable named _. If I made a list of "least favorite things about Zope", that would be at or near the top. Frequently-used variables should not have completely meaningless names. Maybe ZC (nee DC) thought that users wouldn't see that variable very often? It sure comes up a lot on the list. Yet another reason I prefer ZPT over DTML... there's no _ variable and I don't miss it one bit! -- paul winkler home: http://www.slinkp.com music: http://www.reacharms.com calendars: http://www.calendargalaxy.com