Forum OpenACS Development: Re: stable urls for all objects

Collapse
Posted by Timo Hentschel on
That was exactly what i was thinking of. Actually, I wanted to put it in the global /www/ dir, but we could make it a package to be mounted somewhere. I do think this should make it in the core and every package should provide a local url for their objects since we already need that for search, notification and categories.

Here's the code i was thinking of:

db_0or1row get_object_data {
    select o.object_type, n.object_name, o.package_id
    from acs_objects o, acs_named_objects n
    where o.object_id = :object_id
    and n.object_id = o.object_id
}

set package_urls [db_list package_urls {
    select site_node.url(node_id)
    from site_nodes
    where object_id = :package_id
}]

# If there is more than one URL, we pick the first one.
set pkg_url [lindex $package_urls 0]
set impl "$object_type\_idhandler"

if {![acs_sc_binding_exists_p AcsObject $impl]} {
    ad_return_warning "Unable to resolve url"
    return
}

set object_url [acs_sc::invoke -contract AcsObject -operation Url -impl $impl -call_args $object_id]

ad_returnredirect "$pkg_url$object_url"