[Zope] How can i call a pyhton module's function from with in Page Temmplates?

Chris Withers chris at simplistix.co.uk
Tue Oct 18 04:05:17 EDT 2005


Thomas G. Apostolou wrote:
>     <dtml-in expr="GetData(sysDSN=sysDSN, usr=usr, mypass=mypass,
> sTable=sTable, sFields=sFields)">
>       <dtml-if sequence-even>
>         <tr class="even">
>       <dtml-else>
>         <tr class="odd">
>       </dtml-if>
>       <dtml-in sequence-item>
>         <td><dtml-var sequence-item> </td>
>       </dtml-in>
>       </tr>
>     </dtml-in>

What Tino said about using a database adapter is true, but even if you 
want to stick with your external method, you can always use the 
following ZPT:

<tr tal:repeat="data python:GetData(sysDSN=sysDSN,
                                     usr=usr,
                                     mypass=mypass,
                                     sTable=sTable,
                                     sFields=sFields)"
     tal:attributes="python:test(path('repeat/data/odd'),'odd','even')"
   <td tal:repeat="cell data"
       tal:content="cell">
   </td>
</tr>

You only need to figure out where sysDSN, usr, mypass, sTable and 
sFields come from. Your example being in DTML, I have no idea ;-)

cheers,

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk



More information about the Zope mailing list