[Zope3-dev] Paths in ZCML
Jeffrey P Shell
jeffrey@cuemedia.com
Sun, 5 Jan 2003 14:00:09 -0700
On Sunday, January 5, 2003, at 10:36 AM, Steve Alexander wrote:
>> 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.
I think so too. I spent quite a bit of time trying to find how the
path got resolved (NOT an easy trail to follow!) to see if this was in
fact how it worked.
> 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.
I like each of these, leaning a bit more in favor of the latter as it
was what I was expecting to be able to do.
--
Jeffrey P Shell
jeffrey@cuemedia.com