[Zope3-dev] resource names
Marius Gedminas
mgedmin@codeworks.lt
Mon, 5 May 2003 10:59:12 +0300
On Sat, May 03, 2003 at 05:22:35PM -0500, Garrett Smith wrote:
> This problem doesn't show up in page templates since resource names are
> explicitly declared. E.g.
>
> <img src="img/bar.gif" tal:attributes="src context/@@/bar.gif" />
>
> The obvious solution is to store everything in the same directory, which
> is what I'll end up doing.
>
> But couldn't resources break with tradition and use the entire remaining
> path as the resource name? E.g. I could declare a resource as:
>
> <browser:resource
> name="img/bar.gif"
> image="www/img/bar.gif" />
>
> and reference it using "/@@/img/bar.gif".
It is not a good idea to hardcode URLs like "/@@/foo". You cannot be
sure that the resource is available at the root. There are at least two
cases when this is not true:
1) resources provided by a local resource service (which does not exist
yet, but could be written eventually) will not be reachable at the
root.
2) virtual hosting may map a Zope 3 site as a part of another site (for
example, http://www.codeworks.lt/zope3-checkins/ does that and all
the resources live at /zope3-checkins/@@/foo).
When you reference the resource using a TALES expression like
"context/@@/bar.gif", you will get the correct URL in (nearly) all
cases. ("Nearly" because in some cases @@ is not treated as a view name
and you must use "context/++resource++bar.gif".)
Marius Gedminas
--
Codeworks is available for Zope consulting -- http://www.codeworks.lt/