[ZPT] A simpler way?
Chris Withers
chrisw@nipltd.com
Sun, 28 Jul 2002 09:28:45 +0100
Hey Tone :-)
Tony McDonald wrote:
> 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.
Which bit of the construct took the most time to come up with?
> I suppose my question is in two parts really; is there a cleaner way of
> doing the if-then-else construct?
I'd probably to it as:
<td colspan="2" tal:define="isUser
request.SESSION['username']==user.getUserName()">
<tal:x condition="isUser" replace="here/edit_map_bc"/>
<tal:x condition="not:isUser" replace="here/home_map_staff"/>
</td>
...but mixing DTML and ZPT like this will often look horrible :-S
> And is anyone aware of large-scale PT
> projects that I can glean PT-like idioms from?
Zope 3 ;-)
But, there also the language references:
http://www.zope.org/Wikis/DevSite/Projects/ZPT/LanguageSpecifications
...and the tutorial:
http://www.zope.org/Documentation/Articles/ZPT1
http://www.zope.org/Documentation/Articles/ZPT2
cheers,
Chris