Forum OpenACS Q&A: Response to How to get an instance url from a package key?

Collapse
Posted by Stephen . on
I can get the package_id from the package_key, so that's no problem.

You might get duplicates:

SQL> select package_id, package_key, instance_name from apm_packages order by package_key;

PACKAGE_ID PACKAGE_KEY                    INSTANCE_NAME
---------- ------------------------------ ------------------------------
       209 acs-admin                      ACS Administration
       241 acs-api-browser                ACS API Browser
       251 acs-content                    ACS Content
	1113 acs-content-repository         ACS Content Repository
       741 acs-core-docs                  ACS Core Documents
       765 acs-datetime                   ACS DateTime
      1512 acs-developer-support          Developer Support
        96 acs-kernel                     ACS Kernel
	780 acs-mail                       ACS Mail
      1133 acs-messaging                  ACS Messaging
	789 acs-notification               ACS Notification
      1479 acs-subsite                    Main Site
     13050 acs-subsite                    Bar
     13003 acs-subsite                    Foo Site
       333 acs-tcl                        ACS Tcl
       633 acs-templating                 ACS Templating
	 644 acs-util                       ACS Utilities
	1020 acs-workflow                   ACS Workflow
	2050 simple-survey                  Survey
	1478 skin                           Skin

20 rows selected.

I can't find any function in site_node that will return a url.

SQL> select node_id, object_id, name from site_nodes;

   NODE_ID  OBJECT_ID NAME
---------- ---------- ------------------------------
      1504       1479
      1505        209 acs-admin
      1506        741 doc
      1507        241 api-doc
      1510       1512 ds
     13001      13003 foo
      2048       2050 survey
     13034        241 api
     13048      13050 bar
     13086            empty-folder

10 rows selected.


SQL> select site_node.url(node_id) from site_nodes;

SITE_NODE.URL(NODE_ID)
----------------------
/
/acs-admin/
/doc/
/api-doc/
/ds/
/survey/
/foo/
/foo/api/
/bar/
/foo/empty-folder/

10 rows selected.

The object_id in site_nodes is a package_id. You can join against apm_packages to get the URLs of the packages you're interested in, given a package key:

SQL> select p.package_id, site_node.url(n.node_id)
     from site_nodes n, apm_packages p
     where n.object_id = p.package_id
     and p.package_key = 'acs-subsite';
  2    3    4
PACKAGE_ID site_node.url(n.node_id)
---------- ------------------------------
      1479 /
     13003 /foo/
     13050 /bar/

Aren't all the mounts pointing to the same thing?

For your purposes (I'm guessing) no. The testing you want to do will be agianst the database, and you'll need some data, and you'll need to distinguish it from other data. For that you need the package_id. Think of the package_id as an instance_id, it is unique for each mounted instance of a package, and distinguishes one mouonted packages data from another's.