Re: [Re: [Zope] can dtml methods take arguments ?]
Andreas Kostyrka <andreas@mtg.co.at> wrote: On 29 Aug 1999 happyrhino@usa.net wrote:
The name "method" suggests that DTML methods should be able to take arguments much like ZSQL methods can. But for the life of me I can't find where these are added.
Well, just use them ;)
Sorry Andreas, I'm feeling a bit stupid here. You say to just use them so I've been trying variations without any luck. Consider a DTML method "dtmNavigation" which contains the following = <dtml-with "CommonElements"> <TABLE WIDTH=<dtml-var mywidth>> <TR> <!-- ommitted for clarity --> So, I'd like to be able to call it with varying values of 'mywidth'. I've tried to call dtmNavigation with arguments from a DTML document like this = <dtml-var "dtmNavigation(mywidth=120)"> But that produces a very strange result. I then get the following error = Error Type: NameError Error Value: CommonElements How on earth did that crop up ? And how could the DTML method be written so that if no arguments were passed, a default value is used just like standard python functions and methods. ie. def functionname( arg1=defaultvalue1, arg2=defaultvalue2) Or have I totally misunderstood what you meant ? Henry By the way, was there any decision taken on a syntax change from <dtml-tag > to <z-tag > or <dt-tag > because I have to agree that the mere presence of the 'dtml' in the tag makes it much harder to read than the Cold Fusion syntax. ____________________________________________________________________ Get free email and a permanent address at http://www.netaddress.com/?N=1
happyrhino@usa.net wrote:
Andreas Kostyrka <andreas@mtg.co.at> wrote: On 29 Aug 1999 happyrhino@usa.net wrote:
The name "method" suggests that DTML methods should be able to take arguments much like ZSQL methods can. But for the life of me I can't find where these are added.
Well, just use them ;)
Sorry Andreas, I'm feeling a bit stupid here. You say to just use them so I've been trying variations without any luck.
If he says "just use them" he means that a DTML method can automatically see all the variables that are available in the calling document. And thus, by simply using the names, you get what you need. What might confuse you is the term "parameters". It's not what you'd expect when thinking of "formal parameters" such as 'f(int i, float g)' or similar in C. Just think of it as global variables that are visible in your method. Now, enough of philosophy: to see how you can influence these variables available to your method just see the DTML-Guide, looking out for the section about the "let" statement or scanning it for the term "REQUEST.set". In this case the documentation contains everything you need (I've not been all that lucky while working with zope...) . Heiko. -- Heiko Stoermer MIG Augsburg
On 29 Aug 1999 happyrhino@usa.net wrote:
Andreas Kostyrka <andreas@mtg.co.at> wrote: On 29 Aug 1999 happyrhino@usa.net wrote:
The name "method" suggests that DTML methods should be able to take arguments much like ZSQL methods can. But for the life of me I can't find where these are added.
Well, just use them ;)
Sorry Andreas, I'm feeling a bit stupid here. You say to just use them so I've been trying variations without any luck.
Consider a DTML method "dtmNavigation" which contains the following = <dtml-with "CommonElements"> <TABLE WIDTH=<dtml-var mywidth>> <TR> <!-- ommitted for clarity -->
So, I'd like to be able to call it with varying values of 'mywidth'. I've tried to call dtmNavigation with arguments from a DTML document like this = <dtml-var "dtmNavigation(mywidth=120)">
well, you should add also REQUEST=REQUEST, etc. I believe :( Andreas
like standard python functions and methods. ie. def functionname( arg1=defaultvalue1, arg2=defaultvalue2) It cannot. You can use <dtml-unless argument> <dtml-call "REQUEST.set('argument',default)"> </dtml-unless>
By the way, was there any decision taken on a syntax change from <dtml-tag > to <z-tag > or <dt-tag > because I have to agree Yes. It was negative. ;) that the mere presence of the 'dtml' in the tag makes it much harder to read than the Cold Fusion syntax. Well, that's what people told me that often about python's indentation syntax. Well, bad news, it's just syntax, and I consider ignoring syntax (to a certain level) natural for a good developer. (I meant read ignore, write do not ignore ;) )
Andreas -- Andreas Kostyrka | andreas@mtg.co.at phone: +43/1/7070750 | phone: +43/676/4091256 MTG Handelsges.m.b.H. | fax: +43/1/7065299 Raiffeisenstr. 16/9 | 2320 Zwoelfaxing AUSTRIA
participants (3)
-
Andreas Kostyrka -
happyrhinoï¼ usa.net -
Heiko Stoermer