Forum OpenACS Development: Running a Tcl script at package install time

Hi all,

I need to do a bunch of stuff at package install time like creating group types etc, that will be a royal pain if I have to do it all in pl/pgsqlbut quite easy if I use the tcl api(s).

I don't see a "right" way to do it.

I can do it without modifying the acs core by, say, having a line in my package-init.tcl file that chacks a "has_been_installed" flag, and if not then source the init file and set the flag.

Alternatively if people think it's a good idea I can easily modify the apm_install_package function to source a /packages/pkg_key/tcl/pkg_key-create.tcl after loading the sql data model files.

Any opinions?

PS: The new site is cool - and who says good things don't take time - well now that I think about it.... </implicit sarcasm> congrats all involved :)

Collapse
Posted by Tilmann Singer on
There is a post-instantiation mechanism: define a proc package_name_post_instantiation and it will be called everytime you create a new instance of the package from the site-map. For an example look at file_storage_post_instantiation.

You are looking for something else obviously, just though I'd mention that anyway.

I don't see a problem with creating a group-type in plsql though, the tcl proc doesn't do more than call the corresponding plsql function either. What else do you need to do on installation?

Collapse
Posted by Mark Aufflick on
Right now all I want to do is to create some group types and add some parameters to them, although I can imagine that this would be handy elsewhere.

One downside to my idea is that any packages that you depend on need to be "reloaded" if they were installed at the same time as you (either that or insist on a resart before you are installed).

WRT creating group types, the source for group_type::new seems to manually create constraints as well as the various pl/pgsql and table that are associated with each group type. Additionally there don't seem to be any pl/pgsql functions with group_type in their name...

package_name_post_instantiation is cool though - I didn't know that mechanism existed - but it doesn't hel in this case since the process must only be run once, and the package will be installed multiple times.

Collapse
Posted by Tilmann Singer on
Ok, now that I actually looked in the code I see that group_type::new is a bit more complicated than just calling one plsql function.

You could try calling it with -execute_p f and see if the resulting plsql code can be used as a basis to build your create script.