[Zope3-Users] Call a Python method from a ZPT

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Jun 1 08:49:02 EDT 2006


On Monday 29 May 2006 13:49, Paolo Cilmo wrote:
>  In Zope3, i made the same product (package). From a ZPT page (in ZMI), i
> can call a method of Poll if the method don't take arguments, for example
> with: 
>  <span tal:replace="context/poll1/getQuestion">
>  
>  where poll1 is an istance of Poll package and it is in the same folder of
> the ZPT page. This works because the method don't take arguments, i just
> wan't call a method with parameters in Zope3, writing something like: 
>  <span tal:replace="python:context.poll1.getVotesFor(j)"/>

This works like you wrote it, however it is strongly discourage. Instead, you 
should write a view class that does all the logic and just insert the results 
into the template. There is a lot of documentation and code out there that 
describes how to develop views properly.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-users mailing list