AW: [Zope3-dev] Re: AW: override metadirectives before use them notafterwards

Philipp von Weitershausen philipp at weitershausen.de
Tue Apr 27 02:56:13 EDT 2004


Roger,

>>Indeed, we won't have to. I recommend, if you need to override a 
>>directive, create a new one in a different namspace, e.g.
>>
>>   <roger:containerView ... />
> 
> 
> Yes, I know. That's the long way with a lot of work form everybody
> who is using this package.
> 
> Lets make a better example:
> Let's say I whould change the template contents.pt which is imported
> by the class Contents.py in the zope.app.container.browser package. 
> I have different ways to do so:
> 
> 1. Write a own directive <roger:containerView ... /> and use them
>    everywhere.
> 
>    -1, it's to much work for just use another template.
> 
>    -1, needs a lot of changes in many configure.zcml's
>        You have to provide a own configure.zcml lib for this.
> 

I've looked at the code now and I don't like what I'm seeing. 
containerViews makes it quite hard indeed to customize just one 
template. The zope.app.container.browser.contents.Contents has a 
hard-wired reference to the contents.pt template, too. It should really 
use the browser:page directive with the template="" attribute.

The containerViews directive when executed registers as bunch of 
predefined templates for the container. The benefit is that you only 
have to specify the permissions:

<browser:containerViews
      for=".interfaces.IBuddyFolder"
      contents="zope.ManageContent"
      index="zope.View"
      add="zope.ManageContent"
      />

> 4. Override the meta directive and let ZConfig use the new
>    overriden directive.

Again, ZConfig has nothing to do with ZCML. ZConfig bootstraps the 
server (http, ftp, etc.) and the ZODB. That's it.

>    ++1, whould be a clean way for to change basic implementations.
> 
>    +1, I can write a own Contents class and a own contents.pt template
>        and register a new meta directive. I can exactly implement 
>        what's have to replace.

I still believe that overriding a meta directive is not necessary. The 
existing machinery simply needs to be good enough so that it's possible 
to customize every single bit.

So, in order to able to customize IReadContainer's templates, I see two 
possibilities:

1. Get rid of containerViews and have explicit browser:page directives 
(e.g. in zope.app.folder). Container view customizations could choose to 
override any number of those browser:page directives.

2. Use the (not yet implemented) disable directive to disable any call 
to containerViews for the interface/class in question (e.g. 
IReadContainer); then register custom templates for the container 
manually, maybe falling back to Zope3's default templates where 
customization is not necessary.

I prefer #1. I'd be willing to take a shot at it. Nonetheless, we do 
need #2 at some point, but probably not for X3.0.

> Another question is, what's the target.

You probably mean "goal". We're not shooting anyone here :)

> Can anybody help with a easier way. The important part of this problem is,
> it has to work by installing the package without to change directives
> on other packages!

That is the whole idea.

Philipp



More information about the Zope3-dev mailing list