Forum OpenACS Development: Re: Best example package for using the OpenACS permission system, on PostgreSQL?

Thanks for those tips, Gustaf and Antonio.

Yes, it looks like things are mostly the same as with Oracle, but I'm definitely new to the PostgreSQL approach to doing things in OpenACS.

I've been using acs_permission.permission_p from SQL but wasn't familiar with the option to switch to acs_permission.permission_p_recursive_array for large queries. That might be helpful in the future.

When I create a new custom sub-type of acs_object, it looks like the basic approach is still the same, I create MyNewObjectType__new and MyNewObjectType__delete PL/pgSQL functions, and use those as needed.

I think OpenACS expects me to always document my PL/pgSQL functions by calling define_function_args. I'm not quite sure how or where that gets used, but there are adequate examples of how to call it spread around the various packages.

I noticed that many (older?) PostgreSQL packages (like forums) run PL/pgSQL code (e.g., calls to acs_object_type__create_type) from their *-create.sql files by creating, running, and then dropping an inline_0 helper function. It looks like that's no longer necessary though, as other packages just run the same PL/pgSQL function in a select statement, which is certainly more convenient.

For editing permissions on my acs_objects, I see that OpenACS includes a general purpose perm-include widget to do that, which several packages re-use by sticking an include line like this into their own ADP page:

<include src="/packages/acs-subsite/www/permissions/perm-include" &="object_id" &="return_url">

That perm-include widget is certainly fine and helpful, but it can only handle one object at a time. Is there any built-in UI for editing permissions on multiple objects? Or is that left to custom pages specific to each package that wants something like that? (I assume the latter.)

I noticed that many (older?) PostgreSQL packages (like forums) run PL/pgSQL code (e.g., calls to acs_object_type__create_type) from their *-create.sql files by creating, running, and then dropping an inline_0 helper function.

The inline_0 helpers are relicts from earlier versions of PostgreSQL. The trick with the helper can be replaced by DO, which supports anonymous code blocks. DO was introduced by PostgreSQL 9.6.

... define_function_args ...
This function is used to guide calls from Tcl to these functions. If you do not intend to call your own stored functions/procedures from Tcl, this is not needed. Since Tcl does not have function resolution based on types (like e.g. plpgsql) it makes clear what function to call, ... and it provides argument names, when SQL functions are defined without argument names, etc.