Forum OpenACS Q&A: Re: OACSH

Collapse
53: Re: OACSH (response to 36)
Posted by Nis Jørgensen on
I am a newbie too, and I just wrote two pages which do exactly what you suggest (textbox to input tcl/sql, return result to browser). Here's the one for tcl (the sql one I am not happy with yet):

ad_page_contract {
  @Author Nis Jorgensen
} {
  {script:optional {}}
  } -properties {
  result
}

if {!is_sitewide_admin_p} {
  ad_abort_script
}

set result ""

ad_form -form {
    {
      script:text(textarea)
      {label {Input tcl_script}}
      {html {cols 80 rows 10}}
    }
  } -on_submit {
    if {[catch {set result [uplevel $script]}]} {
      global errorInfo
      set result "ERROR:\n$errorInfo"
    }
  }

Collapse
59: Re: OACSH (response to 53)
Posted by Jade Rubick on
I took Nis' page and improved it a bit. Here it is, for posterity:

/www/oacsh.adp

@result@

<formtemplate id="add-edit" style="standard-lars"></formtemplate>
/www/oacsh.tcl
ad_page_contract {
    @author Nis Jorgensen
} {
    {script:optional {}}
} -properties {
    result
}

set user_id [ad_maybe_redirect_for_registration]

if {![string equal $user_id 298]} {
    ad_abort_script
}

set result ""

if {[info exists script]} {
    set script [ad_quotehtml $script]
}

ad_form -name add_edit -form {
    {
        script:text(textarea)
        {label {Input tcl_script}}
        {html {cols 80 rows 10}}
    }
} -on_submit {
    if {[catch {set result [uplevel $script]}]} {
        global errorInfo
        set result "ERROR:
$errorInfo
" } } ad_return_template