Thanks for the detailed response Roger. nice to know this alternative!
However what I and I think David wanted to know is the reason why this
kind of practice cannot be done through the ZMI by entering for example

<html metal:use-macro="views/standard_macros/page">


for a ZPTPage source.

THE REAL ISSUE (in my case) is this. I have a site and I have PAU
principals set. I want to allow these principals to build their own html
pages through a ZMI interface (this is vital) but I don't want them to
enter the whole html source every time. instead I want them to be able
to use macros and viewlets that I have defined with ZCML mainly i want
them to be able to use the main skin.

what is the standard approach to this?

many thanks,
thanks you

Roger Ineichen wrote:
Hi David

Subject: [Zope3-Users] Standard Macros

Is there a way to use standard_macros in a ZPT Page added via the ZMI? In a page registered via ZCML the following METAL is okay, however in a ZPT Page I receive an error regarding a key error for "views".

<html metal:use-macro="views/standard_macros/page">


Any ideas?

Why not use the z3c.macro pattern? I implemented some very handy base patterns which make the *macro as views and mapping* pattern obsolate.


With z3c:macro, you can register macros like:


And use them like:

<tal:block define="title string:My Navigation">
  <metal:block use-macro="macro:title" />

Macros can get registered on context, view and layer
which makes them very handy if you need to provide
different macros for e.g. forms etc.

There is a README.txt file in the package which
explains it in more details. See also zcml.txt
for configuration infos.

And if you like, you can register a macro as a IViewlet within the z3c.macroviewlet package at:

Macro as viewlet sample

This allows you inline definitions of macros which
is very uesfull if you like to design fully working
XHTML/ZPT templates. (without to splitt everything into
own templates). e.g. sample (see
<tal:block replace="structure provider:ITitle">
  <metal:block define-macro="title">
    <title>The title</title>

And if it's not enough, you can take a look at z3c.pagelet if you need more skin simplification.

The pagelet pattern was developed for split the
template and python view class into own components.
I allways like to say the template is the view and the python view class ist the controller if I need
to make a mapping to the MVC pattern.

Roger Ineichen

Warm regards,

Zope3-users mailing list

Zope3-users mailing list

Reply via email to