Forum OpenACS Q&A: Re: Comfortable way of editing parameters?

Collapse
Posted by Frank Bergmann on
Hi Lachlan,

<blockquote> I use the Site Manager
</blockquote>

thanks a lot for the reply. I just discovered /shared/parameters. It does more or less what I want, only that it's only for a single package.

So I've written a short TCL that gives me the list of all system parameter (one view), with the package_key as a link to /shared/parameters for editing. That's not a bulk upload, but already much more confortable when customizing an entire site. I don't know if somebody wants to put this into the CVS...

Bests,
Frank

---

# /packages/intranet-core/www/admin/parameters/index.tcl
ad_page_contract {
  Home page for parameter administration.
  @author mailto:frank.bergmann@project-open.com
} {
    { return_url {[ad_conn url]} }
}

set user_id [ad_maybe_redirect_for_registration]
set user_is_admin_p [im_is_user_site_wide_or_intranet_admin $user_id]

set page_title "Parameters"
set context_bar [ad_context_bar $page_title]
set context ""

set bgcolor(0) " class=rowodd"
set bgcolor(1) " class=roweven"

# ---------------------------------------------------------------
# Render Module List
# ---------------------------------------------------------------

set sql "
select
        p.package_id,
        p.package_key,
        p.instance_name,
        v.attr_value,
        m.parameter_name
from
        apm_packages p,
        apm_parameters m,
        apm_parameter_values v
where
        p.package_key = m.package_key(+)
        and m.parameter_id = v.parameter_id(+)
order by
        p.package_key
"

set old_package_key ""
set ctr 1
set package_html ""
db_foreach packages $sql {
#    if {![regexp {^intranet} $package_key]} { continue }

    if {![string equal $package_key $old_package_key]} {

        append package_html "
<tr class=rowplain colspan=99><td>&nbsp;</td></tr>
<tr class=roweven>
  <td colspan=2>
    <A HREF=/shared/parameters?[export_url_vars package_id return_url]>$package_key</A\
<blockquote></td>
</blockquote>
  <td>$instance_name</td>
</tr>\n"

        set old_package_key $package_key
        set ctr 0
    }

    if {"" == $parameter_name} { set parameter_name "<i>No parameters</i>" }
    append package_html "
<tr $bgcolor([expr $ctr % 2])>
  <td>&nbsp;&nbsp;&nbsp;</td>
  <td>$parameter_name</td>
  <td>$attr_value</td>
</tr>\n"

    incr ctr
}

set parameter_html "
<table border=0>
<!-- <tr>
  <td class=rowtitle>Package Key</td>
  <td class=rowtitle>Package Name</td>
</tr> -->
$package_html
</table>\n"

Collapse
Posted by Malte Sussdorff on
Frank, thanks a lot for posting this script.

To be put into CVS we would first have to port it to postgres but additionaly make it scale in subsites/multiple package instances (as you do not differentiate between singleton packages and others it is very hard to see where a parameter has been set). If you would be willing to continue down this road it would be very good. In the end it would belong to /acs-admin/parameters (in my opinion, feel free to object).