[Zope] Calling a dtml method from a product

Geoff Armstrong geofstro@monaco.mc
Thu, 4 Apr 2002 22:42:26 +0200


Thanks for your input Deiter,

You are correct, of course. After further investigation, I realize 
that passing request as  REQUEST=3D'REQUEST' is not providing what I 
need at all. It got rid of the error message; but it's not allowing 
the called DTML Method to set variables as I'd wished.

I got carried away by my initial enthusiasm for having got rid of the 
error message "REQUEST not defined" into thinking I'd really solved 
the problem; but inspection of the debug window proves otherwise. I'm 
an optimist at heart :)

What I really need to understand here is whether it's possible to 
call a DTMLMethod from a Python product and have it behave exactly as 
though it was called through the web. I find now that even after 
modifying the DTML method in question to get rid of reliance on 
setting request variables, still doesn't stop it from complaining 
about everything not being defined. e.g. calls to objectValues as in 
<dtml-in "objectValues=8A

So can you tell me, is it really possible to call a DTMLMethod from a 
Python product and have it behave exactly as thought it was called 
through the web?

thanks

geoff


>Geoff Armstrong writes:
>  > At 11:03 +0100 4/4/02, hans wrote:
>  >
>  > I managed to solve it with the following:
>  >
>  > myResult_if_any =3D DTMLMethod.DTMLMethod.__call__(self.catalog_items2,
>  > REQUEST=3D'REQUEST')
>Your problem has been the reference to an undefined name REQUEST.
>
>By wrapping REQUEST into a string literal, you no longer reference it
>as a name (or variable).
>
>But you are very lucky, that it works now. There is a really high
>chance that it would not work!
>
>The "REQUEST" argument is expected to be a mapping object not a string.
>Passing a string is worse (maybe equally bad) than not passing REQUEST
>at all!
>
>Furthermore, an additional argument, called "client", is usually
>essential to call DTML objects.
>
>Please read "Calling DTML Objects" in
>
>   <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html>
>
>
>
>
>Dieter


-- 
http://www.imagebites.net/newsland

The most convenient news site on the net!