Index: openacs-4/packages/new-portal/tcl/datasource-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/datasource-procs-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/new-portal/tcl/datasource-procs-oracle.xql 19 Jun 2003 01:59:17 -0000 1.1
@@ -0,0 +1,41 @@
+
+
+
+ oracle8.1.6
+
+
+
+ begin
+ :1 := portal_datasource.new(
+ name => :name,
+ description => :description
+ );
+ end;
+
+
+
+
+
+ begin
+ :1 := portal_datasource.set_def_param(
+ datasource_id => :datasource_id,
+ config_required_p => :config_required_p,
+ configured_p => :configured_p,
+ key => :key,
+ value => :value
+ ):
+ end;
+
+
+
+
+
+ begin
+ portal_datasource.delete(
+ datasource_id => :datasource_id
+ );
+ end;
+
+
+
+
Index: openacs-4/packages/new-portal/tcl/datasource-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/datasource-procs-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/new-portal/tcl/datasource-procs-postgresql.xql 19 Jun 2003 01:59:17 -0000 1.1
@@ -0,0 +1,35 @@
+
+
+
+ postgresql7.1
+
+
+
+ select portal_datasource__new(
+ :name,
+ :description
+ )
+
+
+
+
+
+ select portal_datasource__set_def_param(
+ :datasource_id,
+ :config_required_p,
+ :configured_p,
+ :key,
+ :value
+ )
+
+
+
+
+
+ select portal_datasource__delete(
+ :datasource_id
+ )
+
+
+
+
Index: openacs-4/packages/new-portal/tcl/datasource-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/datasource-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/new-portal/tcl/datasource-procs.tcl 19 Jun 2003 01:59:17 -0000 1.3
@@ -0,0 +1,150 @@
+#
+# Copyright (C) 2001, 2002 MIT
+#
+# This file is part of dotLRN.
+#
+# dotLRN is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+
+ad_library {
+
+ portal datasource procs
+
+ @version $Id: datasource-procs.tcl,v 1.3 2003/06/19 01:59:17 donb Exp $
+
+}
+
+# DRB: fold this into the new portal code ASAP! Also add Simon's datasource_new etc
+# into this namespace when folding
+
+namespace eval portal::datasource {
+
+ ad_proc new_from_spec {
+ -spec:required
+ } {
+
+ Create a new portal datasource from a specification. Why use this to define
+ your portal datasources? Because calling this procedure from your package's
+ post-install procedure is easier than writing PL/SQL for Oracle and PL/pgSQL
+ for Oracle.
+
+ @author Don Baccus (dhogaza@pacifier.com)
+
+ @param spec The specification (format described below)
+
+ The specification is a list of name-value pairs. Possible names are
+
+ name The name of the new datasource
+ description A human-readable description (defaults to name)
+ params A list of param key/attributes and their values
+
+ Each parameter key can be followed by a comma-separated list of attributes
+ in the familiar style of ad_page_contract or ad_form. Do not include spaces
+ in the list of attributes. Only two attributes are allowed - "config_required_p"
+ and "configured_p".
+
+ See the portal package documentation for the meaning of these two attributes.
+
+ An example of a specification:
+
+ { name "my_name"
+ description "my_description"
+ spec { shadeable_p,config_required t
+ hideable_p,configured t
+ }
+ }
+
+ } {
+
+ array set datasource $spec
+
+ # Default datasource description to its name
+ if { ![info exists datasource(description)] } {
+ set datasource(description) $datasource(name)
+ }
+
+ db_transaction {
+
+ set datasource_id [new -name $datasource(name) -description $datasource(description)]
+
+ foreach param $datasource(params) {
+
+ if { ![regexp {^([^ \t:]+)(?::([a-zA-Z0-9_,(|)]*))([ \t]+)(.+)$} \
+ $param match param_name flags blanks value] } {
+ ad_return -code error "Parameter '$param' doesn't have the right format. It must be var\[:flag\[,flag ...\]\] value"
+ }
+
+ # set defaults for attributes
+ set config_required_p f
+ set configured_p f
+
+ # now set the parameter flags
+ foreach flag [split [string tolower $flags] ","] {
+ switch -exact $flag {
+ configured { set configured_p t }
+ config_required { set config_required_p t}
+ default { ad_return -code error "\"$flag\" is not a legal portal datasource attribute" }
+ }
+ }
+
+ # and define the parameter
+ set_def_param -datasource_id $datasource_id \
+ -config_required_p $config_required_p \
+ -configured_p $configured_p \
+ -key $param_name \
+ -value $value
+
+ }
+ }
+ }
+
+ ad_proc -private new {
+ {-name:required}
+ {-description:required}
+ } {
+
+ @author Simon Carstensen (simon@bcuni.net)
+
+ } {
+ return [db_exec_plsql new_datasource {}]
+ }
+
+ ad_proc -private set_def_param {
+ {-datasource_id:required}
+ {-config_required_p:required}
+ {-configured_p:required}
+ {-key:required}
+ {-value:required}
+ } {
+
+ @author Simon Carstensen (simon@bcuni.net)
+
+ } {
+ db_exec_plsql set_def_param {}
+ }
+
+ ad_proc -private delete {
+ {-name:required}
+ } {
+
+ @author Don Baccus (dhogaza@pacifier.com)
+
+ } {
+
+ if { ![db_0or1row get_datasource_id {}] } {
+ ad_return -code error "Datasource \"$name\" does not exist"
+ }
+
+ return [db_exec_plsql delete_datasource {}]
+
+ }
+
+}
Index: openacs-4/packages/new-portal/tcl/datasource-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/datasource-procs.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/new-portal/tcl/datasource-procs.xql 19 Jun 2003 01:59:17 -0000 1.1
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ select datasource_id
+ from portal_datasources
+ where name = :name;
+
+
+
+