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

Jim Anderson ezjab at ieee.org
Wed Mar 10 01:03:43 EST 2004


I've had a few questions on DTML in the past week.
This should be my last DTML question for a while
for serveral reasones:

    1) If I can make this last example work, I'm
        pretty sure that I can do all that I want
        or need to do in DTML. Actually, I want
        to do very little in DTML and quite a
        bit in Python so I don't think I need
        too much DTML capability.
    2) My experiment DTML application will be
        working once the issue below is resolved.
    3) I plan to take the nudging toward ZPT and
        start an experiment application in ZPT.
        Hopefully, I will then be done with
        DTML.

Thanks to Troy Farrell, Chris Withers, and Jonathan

I have a problem using Zope 2.7.0. I've tried Zope on
both a Linux and Windows PC and have the same problem.

I'm working on a DTML method in which I want to
call an external method in a folder, 'F'. F is a subdirectory
of the directory in which the DTML resides. The method,
'M', is in an external module 'M.py', so the path from
the current folder is 'F/M'. My folder has a property,
"Sample", with a value of "Sample Text". The method,
M, returns a string value, "M method".

First I try calling F.M()
    <p>Calling a method</p>
    <dtml_var expr="F.M()">
    <p>After method call</p>




Then I try using the dtml-with tag using F as the object
being pushed on the stack.

    <dtml-with F only>
        <h2>Sample: <dtml-var sample></h2>

        <p>Calling a method</p>
        <dtml_var expr="M()">
        <p>After method call</p>
    </dtml-with>



When this DTML method is run, the output looks like:

    Calling a method

    After method call

    Sample: Sample Text

    Calling a method

    After method call

The sample property renders properly, but not the
method output.  The output does not include the
string returned by method, 'M'. I've experimented with
a number of different possibilities, but I can not get
method 'M' to run.  But I get no error messages either.
I've tried wrapping the calls to 'M' in a dtml-try
statement, but no exception was raised.

When I test my M.py file in the Extension directory,
the python file executes as expected.


Can anyone give me a suggestion on how to get this
method to execute from the DTML when a dtml-call
or dtml-var tag is used?

Jim Anderson







More information about the Zope mailing list