[Zope] Architectural decisions

Matt Hamilton matth at netsight.co.uk
Mon May 24 05:11:47 EDT 2004

> discovered, but also limitations.  Chief amongst the latter is that there
> seems to be no way to use a variable as part of a ZPT path.  For example,
> if
> I have, in each partner subfolder, a template called "environment" which
> contains statements like:
> <span tal:define="global partner HugeInternationalCorporation"/>
> ...and is referred to by generic scripts with:
> <span tal:replace="here/environment | default"/>
> ...then I can provide each template with a cue to the context in which
> it's
> being invoked.  However, I can see no way to do stuff like:
> <h2 tal:content="here/$partner | default">Default Header"</h2>

  The way to do this would be to call a python script that does the logic
and returns the subtemplate eg:

<h2 tal:content="here/getPartner">Default Header</h2>

then a python script called getPartner with your logic to find the
relevent subtemplate:

# assuming a variable in request called mypartner, it could be part of the
# query string eg. url?mypartner=bob
partner = context.REQUEST.mypartner
subtemplate = context.get(partner, 'default_partner_template')
return subtemplate

> So, what I'm really interested in are any tips, experiences or general
> good
> advice that can better help me evaluate the pros and cons of approaches 1)
> and 2).

I would look at skins, as they allow you to organise the templates much
more flexibly.  If you aren't using CMF then look at ChrisM's Standalone
Skins Tool:



Matt Hamilton                                         matth at netsight.co.uk
Netsight Internet Solutions, Ltd.          Business Vision on the Internet
http://www.netsight.co.uk                               +44 (0)117 9090901
Web Design | Zope/Plone Development and Consulting | Co-location | Hosting

More information about the Zope mailing list