[Zope] Filling nested METAL macro slots with ZSQL items

Eric Walstad eric@ericwalstad.com
Wed, 14 Aug 2002 15:46:01 -0700


Hi all,
I am trying to mix nested macros with SQL and REQUEST variables and am 
having trouble getting the ZSQL items into the inner macro slots:

top level folder
     master.html - ZPT that holds "master" macro with one
                   slot: "main"
                   This handles the nav bar, logo, etc.
     portfolio - Folder
         master.html - ZPT with "portfolio" macro that fills
                       the "main" slot in the "master" macro
                       and defines slots: "description",
                       "screen-shots" and "comments"
         project.html - uses the portfolio macro, filling
                       the "description", "screen-shots" and
                       "comments" slots with data from a
                       ZSQL Method.

In project.html I want to make one ZSQL call and use it to fill all the 
"portfolio" macro slots but receive the following error:

Error Type: Undefined
Error Value: project not found in 'project/description', at line 10, 
column 31
(full traceback below)

Apparently my ZSQL isn't getting called or the repeat variable 
("project") isn't available.

How can I stick the ZSQL results into the portfolio macro slots?

Thanks!
Eric.

Code dump follows...

-----------------------------------------------------------------
project.html - ZPT (called like: "portfolio/project.html?p_id=1")
-----------------------------------------------------------------
<html metal:use-macro="here/master.html/macros/portfolio">
   <head>
     <title tal:content="template/title">The Title</title>
   </head>
   <body>
     <span tal:define="project python: container.sqlProjectDataById[p_id]">
	<span metal:fill-slot="description" 
tal:content="project/description">Description goes here</span>
	<span metal:fill-slot="technologies" 
tal:content="project/technologies">Technologies used will go here.</span>	
	<span metal:fill-slot="screen_shots">
		<ul>
         		<li tal:repeat="image 
python:container.sqlProjectImagesById(request[p_id])">
         		<a tal:attributes="href python: 
container.images[image.id].absolute_url()">
                           <img tal:attributes="src python: 
container.images.thumbnails[image.id].absolute_url()">
                         </a>
         		</li>
         	</ul>
	</span>
	<span metal:fill-slot="comments">
		Comments will go here.
	</span>
     </span>
   </body>
</html>


----------------------------
portfolio/master.html - ZPT
----------------------------
<html metal:define-macro="portfolio">
   <head>
     <title tal:content="template/title">Front Page</title>
   </head>
   <body metal:use-macro="container/site.com/master.html/macros/master">
   <span metal:fill-slot="main">
	<table width="500px" border="1" cellspacing="0" cellpadding="1">
	  <tr>
		<td width="100px">Description</td>
		<td colspan="2" width="79%"><span metal:define-slot="description"></span></td>
	  </tr>
	  <tr>
		<td width="100px">Technologies &amp; Software Used</td>
		<td colspan="2" width="79%"><span 
metal:define-slot="technologies"></span></td>
	  </tr>
	  <tr>
		<td colspan="3">Screen Shots</td>
	  </tr>
	  <tr>
		<td colspan="3">
		  <span metal:define-slot="screen_shots">
		  <ol>
			<li>Screen shot one</li>
			<li>Screen shot two</li>
		  </ol>
		  </span>
		</td>
	  </tr>
	  <tr>
		<td colspan="3">Comments</td>
	  </tr>
	  <tr>
		<td colspan="3"><span metal:define-slot="comments"></span></td>
	  </tr>
	</table>
     <a tal:attributes="href container/index.html/absolute_url" 
href="./index.html">Back</a>
</span>
</body>
</html>


--------------------
Error Page Traceback
--------------------
<!--
Traceback (innermost last):
   File 
/data/bin/z251/lib/python/Products/Hotfix_2002-04-15/__init__.py, line 
51, in publish_module
   File /data/bin/z251/lib/python/ZPublisher/Publish.py, line 114, in 
publish
   File /data/bin/z251/lib/python/Zope/__init__.py, line 159, in 
zpublisher_exception_hook
     (Object: portfolio)
   File /data/bin/z251/lib/python/ZPublisher/Publish.py, line 98, in publish
   File /data/bin/z251/lib/python/ZPublisher/mapply.py, line 88, in mapply
     (Object: project.html)
   File /data/bin/z251/lib/python/ZPublisher/Publish.py, line 39, in 
call_object
     (Object: project.html)
   File /data/bin/z251/lib/python/Shared/DC/Scripts/Bindings.py, line 
252, in __call__
     (Object: project.html)
   File /data/bin/z251/lib/python/Shared/DC/Scripts/Bindings.py, line 
283, in _bindAndExec
     (Object: project.html)
   File 
/data/bin/z251/lib/python/Products/PageTemplates/ZopePageTemplate.py, 
line 210, in _exec
     (Object: project.html)
   File 
/data/bin/z251/lib/python/Products/PageTemplates/PageTemplate.py, line 
86, in pt_render
     (Object: project.html)
   File /data/bin/z251/lib/python/TAL/TALInterpreter.py, line 158, in 
__call__
   File /data/bin/z251/lib/python/TAL/TALInterpreter.py, line 191, in 
interpret
   File /data/bin/z251/lib/python/TAL/TALInterpreter.py, line 523, in 
do_useMacro
   File /data/bin/z251/lib/python/TAL/TALInterpreter.py, line 191, in 
interpret
   File /data/bin/z251/lib/python/TAL/TALInterpreter.py, line 523, in 
do_useMacro
   File /data/bin/z251/lib/python/TAL/TALInterpreter.py, line 191, in 
interpret
   File /data/bin/z251/lib/python/TAL/TALInterpreter.py, line 542, in 
do_defineSlot
   File /data/bin/z251/lib/python/TAL/TALInterpreter.py, line 191, in 
interpret
   File /data/bin/z251/lib/python/TAL/TALInterpreter.py, line 542, in 
do_defineSlot
   File /data/bin/z251/lib/python/TAL/TALInterpreter.py, line 191, in 
interpret
   File /data/bin/z251/lib/python/TAL/TALInterpreter.py, line 413, in 
do_insertText_tal
   File /data/bin/z251/lib/python/Products/PageTemplates/TALES.py, line 
265, in evaluateText
   File /data/bin/z251/lib/python/Products/PageTemplates/TALES.py, line 
247, in evaluate
   File /data/bin/z251/lib/python/Products/PageTemplates/Expressions.py, 
line 198, in __call__
   File /data/bin/z251/lib/python/Products/PageTemplates/Expressions.py, 
line 188, in _eval
Undefined: (see above)