[Zope] The old dmtl namespace question

Tom Cameron tom@cameron.to
Wed, 6 Jun 2001 13:45:30 +1000


David,
Thanks for the help, but I am still stuck.
Since I am calling a method in another folder I am a bit stuck.

If I use
1. <dtml-var folder2.method2>
  I get a KeyError error on folder2.method2
  So I try
2. <dtml-var "folder2.method2">
  But it does not render
  So I try
3. <dtml-var "folder2.method2()">
  But it looses the namespace and I get a KeyError on method3
  So I try
4. <dtml-var "folder2.method2( _.None, _ )">
  But it behaves the same as 1.
  So I knock my head on the table and scream!

How do I call a method in another folder and have access to its namespace?

Tom


=> -----Original Message-----
=> From: David McCuskey [mailto:david.mccuskey@bigfoot.com]
=> Sent: Wednesday, 6 June 2001 1:17 PM
=> To: tom@mooball.com; Zope Mailing List
=> Subject: Re: [Zope] The old dmtl namespace question
=>
=>
=> On 6/6/01, Tom enlightened me with:
=>
=> >I am sorry to ask the same question again, but I am still
=> completely stumped
=> >after many hours of trying and reading.
=> >
=> >I have:-
=> >
=> >Folder1
=> >  - method1
=> >Folder2
=> >  - method2  <- this method calls method3
=> >  - method3
=> >
=> >When I call an object like this...
=> >>From  method1
=> ><dtml-call "REQUEST.set('variable','value')">  <- I want to set some
=> >variables too
=> ><dtml-var "folder2.method2">
=> >
=> >The method works perfectly, except that it does not render.
=> >
=> >When I call it like this....
=> >>From method1
=> ><dtml-call "REQUEST.set('variable','value')">
=> ><dtml-var "folder2.method2()">
=> >
=> >It seems to have no namespace at all and causes an error
=> (method2 is calling
=> >method3 and cant find it.)
=> >
=>
=>
=> here are different ways to call methods:
=> 1. <dtml-var method>
=> 2. <dtml-var "method( _.None, _ )">
=> 3. <dtml-var "method()">
=> 4. <dtml-var "method">
=>
=>
=> 1 and 2 are the same: if you don't put quotes or parens, zope will pass
=> _.None and _ for you. 99.99999% of the time you want to use these.
=>
=> 3 is calling the method, but drops the namespace stuff because the
=> namespace variables are not explicitly included in the args. the
=> parameter list is empty.
=>
=> 4 is well, number 4. watch out for number 4. like you said, it calls, but
=> doesn't render.
=>
=>
=>
=>
=> >I have found a few similar posts to the mailing lists and most responses
=> >point to..
=> >http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html
=> >which I have read over and over and still dont understand.
=> >
=> >It mentions _.None, and _ but I cant work out how they work.
=> >
=> >Basically I want method2 to have access to all the methods in folder2 as
=> >well as all REQUEST variables.
=> >
=> >Can someone please show some examples of how to do this.
=>
=> do this:
=>
=> <dtml-var "your_method( _.None, _, param='value', param2='value2' )">
=>
=>
=> my previous reply to "passing parameters to DTML methods" has some
=> discussions and a pointer in the ZDP which i thought were good.
=>
=> check this from dieter:
=>
=>      <dtml-let param1="value1"
=>                param2="value2"
=> 	       ....>
=>        <dtml-XXX method>
=>      </dtml-let>
=>
=> david
=>
=> --
=> David McCuskey
=> david.mccuskey@bigfoot.com
=>
=>