[Zope] HowTo call a Python Method from DTML-Document

hans hans@beehive.de
Fri, 05 Oct 2001 11:08:08 +0100

So far i had only the mailing list digest and compose this msg in an

>>on Thu, 04 Oct 2001 14:03:06 +0100 hans@beehive.de wrote
>>on Zope 2.1.6 (python 1.5.2)
>>==> Python Method Check
>># no parameters, should check REQUEST.form
>># and for each checked form-field add a corresponding
>># diagnostic
>>data = REQUEST.form
>>diag = {}
>>diagnose = 1 # erverything ok
>>if data['fname'   ] == '': # required
>> diag.set('fname'   , 'required' )
>> diagnose = 0
>>==> DTML-Document Form calls
>><dtml-call "Check( ... )">
>>1) this is not documented in Zope Book Appendix B
>>(calling DTML-Docs & DTML-Methods is documented well)

>Florent Guillaume <fg@nuxeo.com> 4 Oct 2001 13:52:09 GMT
>You could use context.REQUEST in the python script here.
Well, i did already. Zope gave

Error Type: NameError
Error Value: context

Ugly, isn't it? Maybe, zope 2.1.6 itself is buggy there
The historic Zope 2.1.6 is also remote, no access to sources.
Or do i have to import some module to access 'context'?

>>2) i tried various parameters (the "..."), none of which works
>>2a) no actual parameters, no formal parameters:
>>obviously, cant reach REQUEST, since zope complains
>>>>nonexistent object or variable REQUEST.
>>>>Info( (), {}, None )
>>2b): giving Check formal Parameter REQ, call Check( REQUEST)
>>results in REQ=the html-string delivered from REQUEST.__call__
>>(the same as <dtml-var REQUEST>) and a string sure has no attribute
>Florent Guillaume <fg@nuxeo.com> 4 Oct 2001 13:52:09 GMT
>Isn't this the old "cached the result of evaluation even when it is
>incorrect" problem ? See Dieter's doc at


Its been half a year since i last read Dieters Book.
I'm amazed how well it has improved compared to my memory.
I will read it again once i find the time.
Still, im wondering why REQUEST was called instead of just passed
as parameter, and is there a way to avoid the calling of (a callable