Версия 2 от 2010-07-08 14:44:33

Убрать это сообщение

Документация по пакетам третьих разработчиков

Браузерные ресурсы

ZRT Resource

When working locally, you may be storing your image resources in a directory. If you have a subfolder called images with an image logo.png. And you have a template, so here is the HTML to insert the logo:

Переключить отображение номеров строк
   1 <img src="./images/logo.png" />

Now you can see that the template locally works. If you view the HTML via Zope, you can see that it is broken. Now, let’s try to register the logo with the system like this:

Переключить отображение номеров строк
   1 <resource
   2    name="logo.png"
   3    file="images/logo.png"
   4    />

Now try again, after restarting Zope 3, you can see that it is still broken!. So, relative path is not correct.

Zope Resource Templates (ZRT) allows for locally working resources to work with Zope 3 as well. It will rewrite text segments in a resource. It is a 3rd party package developed by Stephan Richter for Lovely Systems. The package is available from here: http://pypi.python.org/pypi/z3c.zrtresource Add the following lines to the HTML resource:

Переключить отображение номеров строк
   1 <!--
   2  /* zrt-replace: "./images/logo.png" \
   3                  tal"string:${context/++resource++logo.png}" */
   4 -->

Then convert HTML resource registration to:

Переключить отображение номеров строк
   1 <zrt-resource
   2    name="helloworld.html"
   3    file="helloworld.html"
   4    />