[Zope] ZPT tal:define scoping with METAL
    Chris Withers 
    chrisw at nipltd.com
       
    Fri Sep  5 16:00:14 EDT 2003
    
    
  
Ed Leafe wrote:
>     I'm guessing that the full page isn't being evaluated as it appears, 
> but rather each of the slots is evaluated separately. Is that correct? 
> If so, is there an alternative to having to define the "results" twice 
> (once for each slot)?
METAL substitution happens before an code is evalutated.
So, your div that defines the results is being substituted out.
Either move the define to "myTemplate", in your example, or do something like 
this in the myTemplate:
<html metal:define-macro="main">
<metal:x define-slot="results"
          tal:define="global results python:[]"/>
<metal:x define-slot="leftside"/>
<metal:x define-slot="rightside"/>
</html>
Then in your template:
<html metal:use-macro="myTemplate">
<body>
<!-- This is the very slow query -->
<metal:x fill-slot="results"
          tal:define="global results here/someQuery"/>
         <table metal:fill-slot="leftside">
             <tr tal:repeat="res results">
                 ...
             </tr>
         </table>
         <table metal:fill-slot="rightside">
             <tr tal:repeat="res results">
                 ...
             </tr>
         </table>
</body>
</html>
cheers,
Chris
    
    
More information about the Zope
mailing list