Hi, I think there is a problem in Zope: I have 3 methods: method_a: <dtml-call "method_b"> method_b: <dtml-call "method_c"> method_c: <dtml-return "_.int(1)"> I can call method_a without problems. But if I change it from <dtml-call "method_b"> to <dtml-call "method_b()"> (look at the braces!) I get an error message. I think this is an error in Zope. Can anybody verify this?! I tried to use such a construct in a larger system here. Error Type: NameError Error Value: method_c Traceback (innermost last): File D:\Programme\uZope\lib\python\ZPublisher\Publish.py, line 214, in publish_module File D:\Programme\uZope\lib\python\ZPublisher\Publish.py, line 179, in publish File D:\Programme\uZope\lib\python\Zope\__init__.py, line 202, in zpublisher_exception_hook (Object: ElementWithAttributes) File D:\Programme\uZope\lib\python\ZPublisher\Publish.py, line 165, in publish File D:\Programme\uZope\lib\python\ZPublisher\mapply.py, line 160, in mapply (Object: method_a) File D:\Programme\uZope\lib\python\ZPublisher\Publish.py, line 102, in call_object (Object: method_a) File D:\Programme\uZope\lib\python\OFS\DTMLMethod.py, line 145, in __call__ (Object: method_a) File D:\Programme\uZope\lib\python\DocumentTemplate\DT_String.py, line 502, in __call__ (Object: method_a) File D:\Programme\uZope\lib\python\DocumentTemplate\DT_Util.py, line 335, in eval (Object: method_b()) (Info: method_b) File <string>, line 0, in ? File D:\Programme\uZope\lib\python\OFS\DTMLMethod.py, line 141, in __call__ (Object: method_b) File D:\Programme\uZope\lib\python\DocumentTemplate\DT_String.py, line 502, in __call__ (Object: method_b) File D:\Programme\uZope\lib\python\DocumentTemplate\DT_Util.py, line 335, in eval (Object: method_c) (Info: method_c) File <string>, line 0, in ? NameError: (see above) -- connection reset by Peer _______________________________________________________________________ Dr. Peer Griebel Tel. +49 7581 4831 23 Geschäftsführer Fax. +49 7581 4831 11 Knoll Informationssysteme GmbH http://www.knoll-is.de Dreiköniggasse 17 mailto:peer@knoll-is.de 88348 Saulgau privat: mailto:peer.griebel@gmx.de
"Dr. Peer Griebel" wrote:
Hi,
I think there is a problem in Zope:
I have 3 methods:
method_a: <dtml-call "method_b"> method_b: <dtml-call "method_c"> method_c: <dtml-return "_.int(1)">
I can call method_a without problems. But if I change it from <dtml-call "method_b"> to <dtml-call "method_b()"> (look at the braces!) I get an error message. I think this is an error in Zope. Can anybody verify this?! I tried to use such a construct in a larger system here.
Error Type: NameError Error Value: method_c
The methods must be passed the current namespace or they don't find other methods in it. If you omit () then it is done automatically. Manually you will need (yes, really) <dtml-var "method_b( _.None, _ )"> I used dtml-var instead of dtml-call, because dtml-call returns nothing. ---------------- Hannu
Hi,
I think there is a problem in Zope:
I have 3 methods:
method_a: <dtml-call "method_b"> method_b: <dtml-call "method_c"> method_c: <dtml-return "_.int(1)">
I can call method_a without problems. But if I change it from <dtml-call "method_b"> to <dtml-call "method_b()"> (look at the braces!) I get an error message. I think this is an error in Zope. Can anybody verify this?!
This should be in an FAQ somewhere. When you call a DTML method, the first two parameters passed in are the object on which the method is to operate (which can usually be '_.None'), and the acquisition namespace '_'. If you call method_b with no parameters at all, the current environment is not available to it, and in particular it cannot find method_c because it has nowhere to look for it. Try: <dtml-call "method_b(_.None, _)"> and everything should be fine. See also http://www.zope.org/Documentation/Guides/DTML- HTML/DTML.5.6.2.html which explains exactly what these arguments are, although not how to use them. Actually having read this, it looks (I haven't checked it) as though you should also be able to write: <dtml-call "method_b(mapping=_)"> which is arguably more readable. -- Duncan Booth duncan@dales.rmplc.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan
Duncan Booth wrote:
Try: <dtml-call "method_b(_.None, _)"> and everything should be fine.
Thank you. This works.
See also http://www.zope.org/Documentation/Guides/DTML- HTML/DTML.5.6.2.html which explains exactly what these arguments are, although not how to use them.
This chapter of the document is titled "Using Document Templates from Python". So it is at least a little bit misleading since I'm using it in a Zope method...
Actually having read this, it looks (I haven't checked it) as though you should also be able to write: <dtml-call "method_b(mapping=_)"> which is arguably more readable.
I think all these calling conventions are not intuitive at all. Wouldn't it be better to have these parameters passed by default? Perhaps it is difficult to implement. But a normal user has no reason to think about passing internal variables. All he sees are his own (dtml-)methods where he himself defines the list of parameters. So he never really sees the real definition of the method with all the 'hidden' parameters. But since I now know how to handle method calls I can live with it. Let's put this question in an FAQ. So novices get a chance to work with Zope. My real problem with starting to work with Zope is the lack of some larger system implemented in Zope which uses all these obscure (?) parts of Zope. Once again thank you! -- connection reset by Peer _______________________________________________________________________ Dr. Peer Griebel Tel. +49 7581 4831 23 Geschäftsführer Fax. +49 7581 4831 11 Knoll Informationssysteme GmbH http://www.knoll-is.de Dreiköniggasse 17 mailto:peer@knoll-is.de 88348 Saulgau privat: mailto:peer.griebel@gmx.de
"Dr. Peer Griebel" wrote:
Duncan Booth wrote:
Try: <dtml-call "method_b(_.None, _)"> and everything should be fine.
Thank you. This works.
See also http://www.zope.org/Documentation/Guides/DTML- HTML/DTML.5.6.2.html which explains exactly what these arguments are, although not how to use them.
This chapter of the document is titled "Using Document Templates from Python". So it is at least a little bit misleading since I'm using it in a Zope method...
Actually having read this, it looks (I haven't checked it) as though you should also be able to write: <dtml-call "method_b(mapping=_)"> which is arguably more readable.
I think all these calling conventions are not intuitive at all.
You're right.
Wouldn't it be better to have these parameters passed by default?
Yes.
Perhaps it is difficult to implement. But a normal user has no reason to think about passing internal variables. All he sees are his own (dtml-)methods where he himself defines the list of parameters. So he never really sees the real definition of the method with all the 'hidden' parameters.
The problem is that python expressions were added after all of the calling machinery was implemented. We never intended people to see these method arguments. When we exposed calling method directly with python expressions, the naked ugliness was revealed. We're averse to just changing this straight out because it could break a lot of stuff subtley. I seem to remember Jim mentioning something about changing this, but I don't know the details. In either case, you're wish will go unaswered unless you put it somewhere where it will not flow down the list river never to wash ashore again. How about putting it in the interfaces Wiki? http://www.zope.org/Members/michel/Projects/Interfaces under the InterfacesWishList? -Michel
participants (4)
-
Dr. Peer Griebel -
Duncan Booth -
Hannu Krosing -
Michel Pelletier