[ZPT] eliminated path expressions .. again

jmr@computing.com jmr@computing.com
Fri, 01 Jun 2001 01:59:23 -0500 (CDT)


evan> Try this:
evan> metal:use-macro="python:path('here/chrome/standard/%s/macros/view' %
evan> here.meta_type)"

Is there a way to do this based on a tal-computed variable?  I want
something like this:

<span tal:define="is_auth python:((user.getUserName() == 'Anonymous User') and 'unauth') or 'auth'"
      metal:use-macro="python:path('here/standard_fragments/macros/%s_header' % is_auth)">
</span>

The point is to get the right header; we have "auth_header" and
"unauth_header" defined as macros.  However, I get a Tales name error
on "is_auth".  I presume that's because the macro is expanded before
the tal executes to select which one to expand.... catch-22.

We currently do it with two distinct phrases with contradictory
conditions.. however, this causes both headers to get included in the
expanded source and our homesite users don't like that... :) It works
fine at runtime, though.

Jim Rowan
DCSI
jmr@computing.com