[Zope] python script returning DTMLMethod problem

Maik Jablonski maik.jablonski@uni-bielefeld.de
Wed, 07 Aug 2002 20:03:41 +0200


hi tom,

have a look at http://www.zopelabs.com/cookbook/992031125 for the 
correct syntax calling a DTML-Method from a PythonScript.

must be something like this:

dtmlMethod(context, context.REQUEST)

or if _ is bound to the (Script) Python in the bindings tab

dtmlMethod(context, _)

I guess you need the last one [submitting the whole Namespace to your 
DTMLMethod]!

calling dtmlMethod(context) works only in some special cases, but it is 
not correct at all...

greetings, maik

Tom Germaine wrote:
> Thanks, this solution solves the problem of script returning 
> DTMLMethod:
> <dtml-var standard_html_header>
> <dtml-var REQUEST>
> <dtml-var standard_html_footer>
> but this solution does not help me with my original problem of 
> returning this DTMLMethod:
> <html>
> <head></head>
> <body>
> <h2>AVC files:</h2>
> <dtml-call "REQUEST.set('expand_all',_.int(1))">
> <dtml-tree avc branches_expr="objectValues(['Folder','DTML 
> Document'])" 
>   sort=id>
> <dtml-if "meta_type=='Folder'">
>   <dtml-if expr="title == ''">
>   <dtml-else>
>     <h3><dtml-var title ></h3>
>   </dtml-if>
> </dtml-if>
> 
> <dtml-if "meta_type=='DTML Document'"> 
>   <dtml-if "title == ''"> 
>   <dtml-else>
>     <li><dtml-var id>::&nbsp;<A HREF="&dtml-absolute_url;" 
> target=display>
>     <dtml-var title></a></li>
>   </dtml-if> 
> </dtml-if>
> </dtml-tree> 
> </body>
> </html>
> 
> with error message
> Error Type: KeyError
> Error Value: URL
> 
> Any further suggestions would be appreciated.
> 
> Tom
> 
> On 7 Aug 2002, at 16:24, DA Loeffler wrote:
> 
> 
> 
>>On Wed, 7 Aug 2002, Tom Germaine wrote:
>>
>>
>>>Even if the script:
>>>return context.showUploadRequests()
>>>
>>> calling a simple DTML method:
>>><dtml-var standard_html_header>
>>><dtml-var REQUEST>
>>><dtml-var standard_html_footer>
>>>
>>>fails with error:
>>>Error Type: KeyError
>>>Error Value: standard_html_header
>>
>>This one should work as
>>return context.showUploadRequests(context)
>>
>>Certainly I have written lots of Python scripts which include the line
>>print context.standard_html_header(context)
>>
>>David

-- 
Maik Jablonski                 __o
www.zfl.uni-bielefeld.de     _ \<_    Deutsche Zope User Group
Bielefeld, Germany          (_)/(_)               www.dzug.org