[Zope] problem calling a Python external method in a folder from a DTML method

Paul Winkler pw_lists at slinkp.com
Wed Mar 10 16:19:50 EST 2004


On Wed, Mar 10, 2004 at 11:06:36AM -0500, Jim Anderson wrote:
> Maybe this is part of my problem, but it seems like the path to the 
> external method is
> relevant. Zope must find the external method to run it. Normally, this 
> would be through
> acquisition, but since the method is in a subdirectory of the DTML 
> method referring to
> it, I have used the <dtml-with> to push the namespace of folder F on to 
> the namespace
> stack.

That's fine.
 
> Two things confuse me more.
> 
> First, there is no error message at all. There
> are a couple of possibilities. With a statement like,
>    <dtml-var expr="F.M()">
> maybe Zope does not consider this an external method reference?

The type of object is irrelevant to zope.
All that this says is "In the object F (whatever that is),
get the attribute M (whatever that is) and call it."

> It seems 
> like it
> should, but maybe it doesn't. The syntax I used looks identical to 
> syntax that I've
> see in the Zope Book and Zope Bible. Interestingly, when I remove the
> external method M, the DTML runs the same, implying the Zope never
> looked for M to begin with.

Ahh - good clue, but your interpretation is a bit off.
Zope definitely looked for M, but it very likely found something other
than what you expect. If this were not the case, you would
have got an error that M was not found.
 
> Second, why does it find 'F.sample' a property of F, but not the external
> method M in F? Clearly, F is on the namespace stack.

Yes, but usually lots of other stuff is on the stack too,
and this may be confusing the issue...
 
> >>My folder has a property,
> >>"Sample", with a value of "Sample Text". The method,
> >>M, returns a string value, "M method".
> >>
> >
> >Given the remainder of your message, I am suspicious that
> >your method returns anything at all.
> >
> When I run the test tab in the external method, the return value of the 
> method gets rendered
> by Zope. This is not the problem.

OK, that's good to know. 
That is another strong indication that your DTML 
is finding the wrong thing named M.

What happens if you change your DTML code to this?

    <dtml-var expr="F.M.getPhysicalPath()">

It should print a tuple containing the path to this M object.
e.g. if M lived at /F1/F2/M, it should display this:
('', 'F1', 'F2', 'M')


-- 

Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's SPACE ZOMBIE DEATH!
(random hero from isometric.spaceninja.com)



More information about the Zope mailing list