Beispiel #1
0
    def router(target, absolute=False):
        p = None
        if isinstance(target, Model):
            p = routes_by_key[target.key]

        if hasattr(target, 'key') and target.key in routes_by_key:
            p = routes_by_key[target.key]
        elif hasattr(target, 'slug') and target.slug in routes_by_slug:
            p = routes_by_slug[target.slug]

        if target in routes_by_key:
            p = routes_by_key[target]
        elif target in routes_by_slug:
            p = routes_by_slug[target]

        if p:
            if absolute:
                base = config['url_base']
                return util.url_join(base, p)
            else:
                return p

        raise KeyError(target)
Beispiel #2
0
 def _set_absolute_url(el, key, path):
     url = util.url_join(config['url_base'], path)
     _set_attr(el, key, url)