[Zope] macro context confusion

David Clymer david at zettazebra.com
Tue Oct 12 00:03:15 EDT 2004


Is there a way make a macro get expanded within the context in which it
is called (maybe it always does, and I'm just confused)? For example,
I've got the following slot defined in /standard_template.pt

  <head>
    <metal:block define-slot="head">
    <title tal:content="template/title">The Title</title>
    <link rel="stylesheet" type="text/css"
href="/stylesheets/default.css" tal:attributes="href container/style" />
    </metal:block>
  </head>

and call the encompasing macro in a different directory/file:
/computers/index_html

the variable "container/style" is defined in the / directory as
"/stylesheets/default.css" and in /computers/ as
"/stylesheets/computers.css"

when I test /computers/index_html, the stylesheet remains
/stylesheets/default.css, even when I remove the explicit href="..." and
leave only tal:attributes=.... in the macro. What I'm assuming here is
that the macro must be expanded in the container that the macro is
defined in rather than the container that it is being called in. That or
i'm doing something wrong.

What I'd like is to have a single template that can be used to generate
a page with a different stylesheet depending on where it lies in the
site folder hierarchy. Is there a better way to do this, or at least a
way to fix what I've got?

-davidc



More information about the Zope mailing list