Forum OpenACS Development: Re: stable urls for all objects

Collapse
Posted by Dave Bauer on
Tom,

It really makes sense for packages to have a tcl proc that generates a URL for user-visible objects. We already have a URL service contract for search, and for notifications. Do we need another for categorization, or should be choose a standard service contract that can return the URL of an object?

I have another idea for the index.vuh. It should live at the root of the site, and accept just an interger as the last part of the URL http://example.com/foo/12345.

This would allow creating a URL that contrains an object_id as the last part with an arbitrary path before it. This would allow pretty URLs for packages with less work. Just implement the URL service contract.

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"