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

Jim Anderson ezjab at ieee.org
Wed Mar 10 10:42:23 EST 2004


Dennis Allison wrote:

Dennis, I'm still having troubles. I'll review the acquisition 
information and see
if I've missed something.

>Jim -- 
>Read the manual on acquisition.  I suspect that your external method 
>is not in the acquisition path.
>
Part of my experiment was to use the <dtml-with F> to push the folder F 
on to the namespace stack.
Method M is in F and if I understand correctly, then zope should find 
properties and methods
in F. It does find the property on F, but not the method :(

>
>
>I'd suggest an experiment to learn how it all works.  Put the 
>external method in the same folder with your DTML method.  Does
>it work?
>
I tried putting M in the same folder as the DTML method. This did not 
work either.


>Try puting the external method in the parent folder of 
>the folder in which your DTML method resides.Does
>
>it work?  
>
No luck here either.



>Try creating a folder in the parent call it "EM" and 
>
>put the external method in it, and reference the external method 
>as EM.M.  Does that work. 
>

Again, it does not work.

> Go back to your original folder setup
>and wrap the call in a <dtml-with /...../methodfolder/F> and 
>reference the external method (in F) as M().  Does that work?
>

Zope did not like see slashes in the <dtml-with> statement. But at least 
I got an error message
here.

>
>
>On Wed, 10 Mar 2004, Jim Anderson wrote:
>
>>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
>>
>>
>>
>>
>>
>>_______________________________________________
>>Zope maillist  -  Zope at 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 )
>>
>
>






More information about the Zope mailing list