'Support for sharable URL for a specified repository, e.g. http://example.org/view/owner/name.'

@web.expose
def sharable_repository(self, trans, owner, name):

    try:
        repository = repository_util.get_repository_by_name_and_owner(trans.app, name, owner)
    except:
        repository = None
    if repository:
        repository_id = trans.security.encode_id(repository.id)
        return trans.response.send_redirect(web.url_for(controller='repository', action='index', repository_id=repository_id))
    else:
        try:
            user = common_util.get_user_by_username(trans, owner)
        except:
            user = None
        if user:
            user_id = trans.security.encode_id(user.id)
            message = ('This    list    of    repositories    owned    by    <b>%s</b>,    does    not    include    one    named    <b>%s</b>.' % (str(owner), str(name)))
            return trans.response.send_redirect(web.url_for(controller='repository', action='index', user_id=user_id, message=message, status='error'))
        else:
            return trans.show_error_message(('The    tool    shed    <b>%s</b>    contains    no    repositories    named    <b>%s</b>    with    owner    <b>%s</b>.' % (web.url_for('/', qualified=True).rstrip('/'), str(name), str(owner))))
