Package advene :: Package model :: Module tales :: Class WithAbsoluteUrlMixin
[hide private]
[frames] | no frames]

Class WithAbsoluteUrlMixin

source code

object --+
         |
        WithAbsoluteUrlMixin
Known Subclasses:


This class provides a common implementation for the ``absolute_url`` tales
function.

``absolute_url`` is supposed to return an URL where one can retrieve a
*description* of an object (this is *not* the URL where a package can be
downloaded, nor the URI-ref of an element). It is intensively used in
HTML views served by the embedded HTTP server in the Advene tool.

``absolute_url`` is expected to consume the rest of the TALES path, and
suffix it to its return value. E.g::
      some_element/absolute_url/content_data
      -> http://localhost:1234/packages/p/some_element/content_data

      some_package/absolute_url/annotations
      -> http://localhost:1234/packages/some_package/annotations

But if no URL can be constructed, it returns None.

This mixin provides all the bells and whistles to do so. It relies on
the presence of two TALES variables:
 * options/packages (mandatory) contains a dict whose keys are package
   names, and whose values are package instances
 * options/base_url (optional) contains the reference URL

The returned value will be of the form::
  base_url/specific/rest/of/the/path
where ``specific`` is computed by a method from the mixed-in class, of the
form::

  def _compute_absolute_url(self, packages)

and this method should invoke `self._absolute_url_fail()` if it can not
construct a URL (resulting in the TALES path failing to evaluate).

Instance Methods [hide private]
 
_tales_absolute_url(self, context)
See class documentation.
source code
 
_absolute_url_fail(self, msg='') source code

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_tales_absolute_url(self, context)

source code 

See class documentation.

Decorators:
  • @tales_property