You are not logged in Log in Join
You are here: Home » Members » Stefan's Home » ExtFile/ExtImage » Using static URLs with ExtFile/ExtImage » View Document

Log in
Name

Password

 

Using static URLs with ExtFile/ExtImage

We can use Apache to serve ExtFiles and ExtImages directly from the repository, without involving Zope. All we need to do is set the EXTFILE_STATIC_PATH environment variable in the <environment> section of etc/zope.conf.

EXTFILE_STATIC_PATH specifies the path Apache can use to access the repository. This depends on your virtual host configuration (see below).

If EXTFILE_STATIC_PATH is set, ExtFile enters static-mode. This means that the tag, link, and preview APIs of ExtFile and ExImage will generate static URLs, i.e. URLs that point to Apache, not back to Zope.

There is one quirk: The absolute_url API always returns the URL of the ZODB object, even in static-mode. ExtFiles have a separate static_url API, which you must use in place of absolute_url should you need to construct things like <img> or <a> tags by hand. It's best to leave the work to tag, link, and friends though.

Note that repository files must have file extensions for Apache to get the MIME headers right! ExtFile can help you here - and in fact does so by default. See the extensions option in extfile.ini.

Example etc/zope.conf:

  <environment>
    EXTFILE_STATIC_PATH /static
  </environment>

Example vhost:

  <VirtualHost 10.0.0.1>
    RewriteEngine on
    RewriteRule ^/static/(.*)  /path/to/instance/static/reposit/$1 [L]
    RewriteRule ^/(.*)         http://localhost:8080/ ... [P,L]
  </VirtualHost>

If you want to use a separate server for static content, specify its hostname in the EXTFILE_STATIC_HOST environment variable. ExtFile will then use this name when constructing static URLs.

You may also be interested in this post: http://mail.zope.org/pipermail/zope/2003-April/134366.html.