attachments::get_attachments_url (private)

 attachments::get_attachments_url [ -base_url base_url ]

Defined in packages/attachments/tcl/attachments-procs.tcl

As 'attachments::get_url' returns the value of the attachments package 'RelativeUrl' parameter, which can change at any time, it could happen that previously mounted attachments have a different url and are not found anymore. We try our best here to find a mounted attachments package under 'base_url' to mitigate this, probably flawed, package logic. In the future, probably a better method should be used for URL resolving that is not so broken. The whole thing is even more weird, as the attachments package is currently a singleton that auto-mounts on /attachments, so i am tempted to replace this whole thing with just that, but anyway...

Switches:
-base_url (optional)
The base URL where to look for the attachments package.
Returns:
The attachments package URL under 'base_url', or "" if none is found.
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 test_attachments_url_api attachments_url_api (test attachments) attachments::get_attachments_url attachments::get_attachments_url test_attachments_url_api->attachments::get_attachments_url ad_conn ad_conn (public) attachments::get_attachments_url->ad_conn attachments::get_url attachments::get_url (public) attachments::get_attachments_url->attachments::get_url site_node::get_children site_node::get_children (public) attachments::get_attachments_url->site_node::get_children site_node::get_from_url site_node::get_from_url (public) attachments::get_attachments_url->site_node::get_from_url site_node::get_node_id site_node::get_node_id (public) attachments::get_attachments_url->site_node::get_node_id attachments::add_attachment_url attachments::add_attachment_url (public) attachments::add_attachment_url->attachments::get_attachments_url attachments::detach_url attachments::detach_url (public) attachments::detach_url->attachments::get_attachments_url attachments::goto_attachment_url attachments::goto_attachment_url (public) attachments::goto_attachment_url->attachments::get_attachments_url

Testcases:
attachments_url_api
Source code:
        if {![ns_conn isconnected]} {
            return "${base_url}[attachments::get_url]"
        } else {
            #
            # Get some context
            #
            set url             "[ad_conn package_url]${base_url}"
            set relative_url    "${url}[attachments::get_url]"
            #
            # Is this URL an attachments package? Otherwise try to find one...
            #
            set package_key [dict get [site_node::get_from_url -url "$relative_url"] package_key]
            if {$package_key eq "attachments"} {
                return $relative_url
            } else {
                set url_node_id [site_node::get_node_id -url $url]
                return [site_node::get_children  -package_key "attachments"  -element "url"  -node_id $url_node_id]
            }
        }
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/attachments/tcl/attachments-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: