Acquisition from a DTML method in a subdirectory
I'm running Zope 2.7.0 on a windows platform and I have a DTML method referenced in a subdirtory from a DTML document object. I want to run and external method from the DTML method, but Zpublisher is giving me an error message that the external method resource is causing a name error and the external method is not defined. My ZMI structure looks like this: root | A | Adtml_doc Aext_method B | Bdtml_method Adtml_doc has the following code: <dtml-var expr="B.Bdtml_method()"> Bdtml_method has code that calls Aext_method in A: Hi! <dtml-var expr="Aext_method()"> Bye! If I run the 'view' tab for Bdtml_method, the method runs as expected and if I assume that the method returns 'Good', my output is: Hi! Good Bye! If I run Adtml_doc, I then get the error message that Aext_method is not defined. If I place a copy of Aext_method in the B, and run Adtml_doc, I still get an error message. I was expecting that the Bdtml_method would find Aext_method by aquiring it from the A, but this does not seem to be the case. So it seems that calling a dtml method in a subdirectory does not acquire from the subdirectory or the current directory? Can anyone explain this? More importantly what is the proper way to call an external method from a dtml method being referenced in a subdirectory? Jim Anderson
Try changing Adtml_doc to <dtml-var expr="B.Bdtml_method(_.None,_)"> If that solves the problem, a zopista greater than I can explain why. If not, all I can say is that I don't use DTML any more :( Troy Jim Anderson wrote:
I'm running Zope 2.7.0 on a windows platform and I have a DTML method referenced in a subdirtory from a DTML document object. I want to run and external method from the DTML method, but Zpublisher is giving me an error message that the external method resource is causing a name error and the external method is not defined.
My ZMI structure looks like this:
root | A | Adtml_doc Aext_method B | Bdtml_method
Adtml_doc has the following code:
<dtml-var expr="B.Bdtml_method()">
Bdtml_method has code that calls Aext_method in A:
Hi! <dtml-var expr="Aext_method()"> Bye!
If I run the 'view' tab for Bdtml_method, the method runs as expected and if I assume that the method returns 'Good', my output is:
Hi! Good Bye!
If I run Adtml_doc, I then get the error message that Aext_method is not defined. If I place a copy of Aext_method in the B, and run Adtml_doc, I still get an error message.
I was expecting that the Bdtml_method would find Aext_method by aquiring it from the A, but this does not seem to be the case.
So it seems that calling a dtml method in a subdirectory does not acquire from the subdirectory or the current directory? Can anyone explain this?
More importantly what is the proper way to call an external method from a dtml method being referenced in a subdirectory?
Jim Anderson
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- And the glory of the LORD shall be revealed, and all flesh shall see it together: for the mouth of the LORD hath spoken it. Isaiah 40.5
Troy, Thank you for the reply. This fixed my problem. It would be interesting to get an explanation on the arguements and why they work. Jim Troy Farrell wrote:
Try changing Adtml_doc to
<dtml-var expr="B.Bdtml_method(_.None,_)">
If that solves the problem, a zopista greater than I can explain why. If not, all I can say is that I don't use DTML any more :(
Troy
Jim Anderson wrote:
I'm running Zope 2.7.0 on a windows platform and I have a DTML method referenced in a subdirtory from a DTML document object. I want to run and external method from the DTML method, but Zpublisher is giving me an error message that the external method resource is causing a name error and the external method is not defined.
My ZMI structure looks like this:
root | A | Adtml_doc Aext_method B | Bdtml_method
Adtml_doc has the following code:
<dtml-var expr="B.Bdtml_method()">
Bdtml_method has code that calls Aext_method in A:
Hi! <dtml-var expr="Aext_method()"> Bye!
If I run the 'view' tab for Bdtml_method, the method runs as expected and if I assume that the method returns 'Good', my output is:
Hi! Good Bye!
If I run Adtml_doc, I then get the error message that Aext_method is not defined. If I place a copy of Aext_method in the B, and run Adtml_doc, I still get an error message.
I was expecting that the Bdtml_method would find Aext_method by aquiring it from the A, but this does not seem to be the case.
So it seems that calling a dtml method in a subdirectory does not acquire from the subdirectory or the current directory? Can anyone explain this?
More importantly what is the proper way to call an external method from a dtml method being referenced in a subdirectory?
Jim Anderson
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
The short reason that this works is that using expr="some_method()" calls that method without passing the namespace to it. The underscore variable ("_") is the namespace variable (or something like that.) If you don't use expr="", you can use name="" naming the function without () to accomplish the same thing. Note that you cannot (to my knowledge) do name="B.Bdtml_method" because the "B." portion of that is an expression, hence Chris mentionning <dtml-with B> Troy Jim Anderson wrote:
Troy,
Thank you for the reply. This fixed my problem. It would be interesting to get an explanation on the arguements and why they work.
Jim
Troy Farrell wrote:
Try changing Adtml_doc to
<dtml-var expr="B.Bdtml_method(_.None,_)">
If that solves the problem, a zopista greater than I can explain why. If not, all I can say is that I don't use DTML any more :(
Troy
Jim Anderson wrote:
Try changing Adtml_doc to
<dtml-var expr="B.Bdtml_method(_.None,_)">
the 1st argument is the client object, passing _.None means "there is no client object", which is fine most of the time. _ is the namespace, which is where all the names you use are looked up. The original way you were calling this passed no namespace, hence nothing could be found bar what could be acquired from B itself. ...and all this is why DTML sucks, and why you should learn ZPT as soon as you can... ;-) Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Jim Anderson wrote:
Adtml_doc has the following code:
<dtml-var expr="B.Bdtml_method()">
change to: <dtml-with B> <dtml-var Ddtml_method> </dtml-with>
Bdtml_method has code that calls Aext_method in A:
Hi! <dtml-var expr="Aext_method()"> Bye!
change to: <dtml-var Aext_method>
So it seems that calling a dtml method in a subdirectory does not acquire from the subdirectory or the current directory? Can anyone explain this?
DTML sux ;-)
More importantly what is the proper way to call an external method from a dtml method being referenced in a subdirectory?
I believe it's caleld ZPT... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Chris, Thanks for the advice. I'm still new and learning Zope. I'm planning to move onto ZPTs soon, but I wanted to experiment and learn about DMTL first. Jim Chris Withers wrote:
Jim Anderson wrote:
Adtml_doc has the following code:
<dtml-var expr="B.Bdtml_method()">
change to:
<dtml-with B> <dtml-var Ddtml_method> </dtml-with>
Bdtml_method has code that calls Aext_method in A:
Hi! <dtml-var expr="Aext_method()"> Bye!
change to:
<dtml-var Aext_method>
So it seems that calling a dtml method in a subdirectory does not acquire from the subdirectory or the current directory? Can anyone explain this?
DTML sux ;-)
More importantly what is the proper way to call an external method from a dtml method being referenced in a subdirectory?
I believe it's caleld ZPT...
Chris
Jim Anderson wrote:
Thanks for the advice. I'm still new and learning Zope. I'm planning to move onto ZPTs soon, but I wanted to experiment and learn about DMTL first.
Are you a masochist? ;-) Just go straight to ZPT... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Chris, Maybe just a bit of a masochist - LOL. I've started reading more about ZPT, and it looks like it will help. I haven't gotten to far yet, but I haven't dumped DTML from my vocabulary yet because I have a concern about tieing ZPT with python modules. I haven't seen how to do that yet. Give me a bit more time on reading then maybe I'll be ok with ZPT. The Zope Book encourages using ZPT, but also says that there are times to use DTML. I need to be able to program a lot of logic and tie it in with the presentation. I'm getting to the point with DTML where I think I can do that with most of my work in python, and a sprinkling of DTML. I'm not quite there yet, however :( Jim Chris Withers wrote:
Jim Anderson wrote:
Thanks for the advice. I'm still new and learning Zope. I'm planning to move onto ZPTs soon, but I wanted to experiment and learn about DMTL first.
Are you a masochist? ;-)
Just go straight to ZPT...
Chris
Jim Anderson wrote:
Maybe just a bit of a masochist - LOL. I've started reading more about ZPT, and it looks like it will help. I haven't gotten to far yet, but I haven't dumped DTML from my vocabulary yet because I have a concern about tieing ZPT with python modules.
What do you mean?
I haven't seen how to do that yet. Give me a bit more time on reading then maybe I'll be ok with ZPT. The Zope Book encourages using ZPT, but also says that there are times to use DTML.
There are never times to use DTML ;-)
I need to be able to program a lot of logic and tie it in with the presentation. I'm getting to the point with DTML where I think I can do that with most of my work in python, and a sprinkling of DTML. I'm not quite there yet, however :(
Yeah, do most of the work in Script (Python)'s, and then present that work using ZPT. ZPT is good in that it gives you good hints as to when stuff should be in a python script... cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
On Wed, Mar 10, 2004 at 02:13:19PM +0000, Chris Withers wrote:
Jim Anderson wrote:
Maybe just a bit of a masochist - LOL. I've started reading more about ZPT, and it looks like it will help. I haven't gotten to far yet, but I haven't dumped DTML from my vocabulary yet because I have a concern about tieing ZPT with python modules.
What do you mean?
I haven't seen how to do that yet. Give me a bit more time on reading then maybe I'll be ok with ZPT. The Zope Book encourages using ZPT, but also says that there are times to use DTML.
There are never times to use DTML ;-)
Sure there are. ZPT is XML-centric and not everything wants to be XML (or a python script). Examples are dynamic stylesheets a la Plone, and Z SQL methods. Other than those 2 examples, I use ZPT for all templates.
I need to be able to program a lot of logic and tie it in with the presentation. I'm getting to the point with DTML where I think I can do that with most of my work in python, and a sprinkling of DTML. I'm not quite there yet, however :(
Yeah, do most of the work in Script (Python)'s, and then present that work using ZPT. ZPT is good in that it gives you good hints as to when stuff should be in a python script...
+1 -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's AGENT OF ATLANTIS! (random hero from isometric.spaceninja.com)
Paul Winkler wrote:
Sure there are. ZPT is XML-centric and not everything wants to be XML (or a python script). Examples are dynamic stylesheets a la Plone, and Z SQL methods.
It's easy enough to generate non-xml stuff using ZPT. There are some rough edges, but nothing a mode for a 'text/plain' content type wouldn't solve... cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (4)
-
Chris Withers -
Jim Anderson -
Paul Winkler -
Troy Farrell