[Zope3-dev] Paths in ZCML

Steve Alexander steve@cat-box.net
Sun, 05 Jan 2003 19:36:40 +0200


> My code looks like this (it's living in a package called 'js.rest')::
> 
>   <browser:page
>     for=".interfaces.IReSTDocument"
>     name="preview.html"
>     menu="zmi_views"
>     title="Preview"
>     template="../../src/zope/app/browser/content/preview.pt"
>     permission="zope.ManageContent"
>     />
> 
> As you can see, the `template` argument has to go '../..' to get back to 
> the Zope 3 root, which requires my root package 'js' to always be in the 
> root as well.  Has there been any thought to how to deal with this 
> situation?  I noticed it when wanting to use the default 'document.gif' 
> icon as well, but I just copied that to my package.

I think refering to the template as relative to a package is better than 
assuming things about the places packages have been installed.
How about this:

    <browser:page
      for=".interfaces.IReSTDocument"
      name="preview.html"
      menu="zmi_views"
      title="Preview"
      template_package="zope.app.browser.content"
      template="preview.pt"
      permission="zope.ManageContent"
      />

An alternative is to introduce a package:file syntax:

    <browser:page
      for=".interfaces.IReSTDocument"
      name="preview.html"
      menu="zmi_views"
      title="Preview"
      template="zope.app.browser.content:preview.pt"
      permission="zope.ManageContent"
      />

This latter syntax would work for the icon directive too, I guess.

--
Steve Alexander