[Zope3-Users] Standard Macros

Hassan Alirezaei hassan at isi.imi.i.u-tokyo.ac.jp
Sun Feb 11 16:36:26 EST 2007


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">

</html>

---------------------------
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">
>>
>> </html>
>>
>> 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.
>
> See:
> svn//svn.zope.org/repos/main/z3c.macro
>
> With z3c:macro, you can register macros like:
>
> <configure
>     xmlns:z3c="http://namespaces.zope.org/z3c">
>   <z3c:macro
>       name="title"
>       template="macro.pt"
>       />
> </configure>
>
> And use them like:
>
> <tal:block define="title string:My Navigation">
>   <metal:block use-macro="macro:title" />
> </tal:block>
>
> 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:
> svn//svn.zope.org/repos/main/z3c.macroviewlet
>
> Macro as viewlet sample
> -----------------------
>   <z3c:macroViewlet
>       for="*"
>       template="template.pt"
>       macro="title"
>       manager="z3c.skin.pagelet.ITitle"
>       layer="z3c.skin.pagelet.IPageletBrowserSkin"
>       />
>
> 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.
>
> template.pt sample (see z3c.skin.pagelet)
> -----------------------------------------
> <tal:block replace="structure provider:ITitle">
>   <metal:block define-macro="title">
>     <title>The title</title>
>   </metal:block>
> </tal:block>
>
> And if it's not enough, you can take a look at 
> z3c.pagelet if you need more skin simplification.
>
> btw
> 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.
>
> Regards
> Roger Ineichen
> _____________________________
> END OF MESSAGE
>
>
>   
>> Warm regards,
>> David
>>     
>
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
>
>
>   



More information about the Zope3-users mailing list