[ZPT] A simpler way?

Tony McDonald tony.mcdonald@ncl.ac.uk
Sat, 27 Jul 2002 15:17:09 +0100


Hi all,
I'm in the process of changing large quantities of our zope site
(http://medical.faculty.ncl.ac.uk/) to use page templates. The main reason
for using PT is the macro facility, which I find really useful.

Thing is I'm coming across constructs like this;

<td colspan="2">
<dtml-in user_fromCode>
<dtml-if "AUTHENTICATED_USER.getUserName()==username">
 <dtml-var edit_map_bc>
<dtml-else>
 <dtml-var home_map_staff>
</dtml-if>
</dtml-in>
</td>

Where edit_map_bc and home_map_staff are both DTML snippets.

The equivalent in PT is this;
<td colspan="2" tal:content="structure
python:test(request.SESSION['username']==user.getUserName(),
here.edit_map_bc(here, request), here.home_map_staff(here, request))">
What user map to show.
</td>

I've been doing PT for quite some time now, but that little construct took
*ages* to figure out.

I've contributed to the effort at ZopeLabs with my own small PT snippets,
but there seems to be a dearth of PT material around to learn from.

I suppose my question is in two parts really; is there a cleaner way of
doing the if-then-else construct? And is anyone aware of large-scale PT
projects that I can glean PT-like idioms from?

Cheers
Tone.
-- 
Dr Tony McDonald,  Assistant Director, FMCC, http://www.fmcc.org.uk/
The Medical School, Newcastle University Tel: +44 191 243 6140
A Zope list for UK HE/FE  http://www.fmcc.org.uk/mailman/listinfo/zope