[Zope] More Calling Dtml-Methods with variable names
Tom Cameron
tom@cameron.to
Sat, 23 Jun 2001 13:47:58 +1000
Jeremiah,
I went through this a week or so ago.
You need to use the <dtml-with> statement to get methods in other folders.
the "folder.method" construct only works if you dont need the namespace of
the other folder.
i.e.
<dtml-var standard_html_header>
<dtml-with Methods>
<dtml-var someMethod>
</dtml with>
<p> That's all. </p>
<dtml-var standard_html_footer>
in this case you should not have to use
_.getitem(someMethod,1)
Tom
=> -----Original Message-----
=> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
=> Jeremiah White
=> Sent: Saturday, 23 June 2001 1:30 PM
=> To: zope@zope.org
=> Subject: [Zope] More Calling Dtml-Methods with variable names
=>
=>
=> OK, I have a small problem now.
=>
=> This is my main DTML document1:
=>
=> <dtml-var standard_html_header>
=> <dtml-var expr="_.getitem(someMethod,1)">
=> <p> That's all. </p>
=> <dtml-var standard_html_footer>
=>
=>
=> Let's say the variable someMethod holds the string 'Method1'.
=>
=> The DTML Method 'Method1' holds this:
=>
=> <h1> HELLO </h1>
=>
=>
=> This actually outputs what you would expect:
=>
=> 'header stuff'
=> HELLO (bold)
=> That's all.
=> 'footer stuff'
=>
=> But what if Method1 is not in the same folder? For example, if
=> it's in the folder 'Methods' which is in the folder that the
=> main document is in. I can't seem to get that to work. I've tried this:
=>
=> <dtml-var expr="_.getitem('Methods.'+someMethod,1)">
=>
=> and I've tried changing the variable name to 'Methods.Method1',
=> but each of these gives me an error:
=>
=> This resource may be trying to reference a nonexistent object or
=> variable Methods.Method1.
=>
=> Using Methods.Method1() does not make a difference.
=>
=> If I just put in <dtml-var expr="Methods.Method1()"> it works.
=> Not what I want though.
=>
=> Thanks for you time reading through this message. I'm really
=> just experimenting with Zope right now, trying to learn what it
=> can do and how it accomplishes those things. I have a feeling
=> some experienced Zope users are laughing hysterically at some of
=> the things I'm doing!
=>
=> -Jeremiah
=>
=>
=>
=>
=>
=>
=> Get more from the Web. FREE MSN Explorer download :
http://explorer.msn.com