Forum OpenACS Q&A: How to instatiate an apm_package with xotcl?

I want to instatiate an apm_package object given the package_id. I got so far. This will return

set c [::xo::db::Class get_class_from_db -object_type apm_package]

This will return ::xo::db::apm_package. Unfortunately

$c get_instance_from_db -id $package_id

fails. Due to the fact that get_instance_from_db is not supported.

$c info instprocs results to

insert save.

Any chance to instantiate the package?

Collapse
Posted by Gustaf Neumann on
Look at the following snippet. There was a small bug in xotcl-core (using the not-fully qualified attribute name "package_id" clashed for this case) which i have fixed just now in cvs head.

set package_id 1762
::xo::db::Class get_class_from_db -object_type apm_package
::xo::db::Class get_instance_from_db -id $package_id
$package_id serialize

Btw, the best way to query all the available methods of an XOTcl object is e.g.

$package_id info methods

I am not sure, why you want to create package-objects in your code, for most applications this is not needed. For creating xowiki/s5/.. instances you should use e.g. "::xowiki::Package initialize ...", which does much more than just the simple object fetch.