This is an automated email from the ASF dual-hosted git repository. mxmanghi pushed a commit to branch 3.0 in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git
commit 6c2ae4ec134d34a999de5a41cfaa6983985264ff Author: Massimo Manghi <mxman...@apache.org> AuthorDate: Fri Nov 2 01:18:44 2018 +0100 merging diff from master concerning package dio --- rivet/packages/dio/dio_Mysql.tcl | 49 ++++++++++++++++-------------- rivet/packages/dio/dio_Oracle.tcl | 36 +++++++++++----------- rivet/packages/dio/dio_Postgresql.tcl | 16 +++++----- rivet/packages/dio/dio_Sqlite.tcl | 2 +- rivet/packages/dio/diodisplay.tcl | 56 +++++++++++++++++------------------ 5 files changed, 81 insertions(+), 78 deletions(-) diff --git a/rivet/packages/dio/dio_Mysql.tcl b/rivet/packages/dio/dio_Mysql.tcl index cf2f376..d9a85ad 100644 --- a/rivet/packages/dio/dio_Mysql.tcl +++ b/rivet/packages/dio/dio_Mysql.tcl @@ -1,18 +1,21 @@ -# dio_Mysql.tcl -- Mysql backend. - -# Copyright 2002-2004 The Apache Software Foundation - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# -- dio_Mysql.tcl -- Mysql backend. + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. # $Id$ @@ -31,8 +34,8 @@ namespace eval DIO { eval configure $args - if {[lempty $db]} { - if {[lempty $user]} { + if {[::rivet::lempty $db]} { + if {[::rivet::lempty $user]} { set user $::env(USER) } set db $user @@ -46,15 +49,15 @@ namespace eval DIO { method open {} { set command "mysqlconnect" - if {![lempty $user]} { lappend command -user $user } - if {![lempty $pass]} { lappend command -password $pass } - if {![lempty $port]} { lappend command -port $port } - if {![lempty $host]} { lappend command -host $host } + if {![::rivet::lempty $user]} { lappend command -user $user } + if {![::rivet::lempty $pass]} { lappend command -password $pass } + if {![::rivet::lempty $port]} { lappend command -port $port } + if {![::rivet::lempty $host]} { lappend command -host $host } if {[catch $command error]} { return -code error $error } set conn $error - if {![lempty $db]} { mysqluse $conn $db } + if {![::rivet::lempty $db]} { mysqluse $conn $db } } method close {} { @@ -104,7 +107,7 @@ namespace eval DIO { } method sql_limit_syntax {limit {offset ""}} { - if {[lempty $offset]} { + if {[::rivet::lempty $offset]} { return " LIMIT $limit" } return " LIMIT [expr $offset - 1],$limit" diff --git a/rivet/packages/dio/dio_Oracle.tcl b/rivet/packages/dio/dio_Oracle.tcl index d0e0a44..c2b51d1 100644 --- a/rivet/packages/dio/dio_Oracle.tcl +++ b/rivet/packages/dio/dio_Oracle.tcl @@ -24,16 +24,16 @@ namespace eval DIO { constructor {args} {eval configure $args} { if {[catch {package require Oratcl}]} { - return -code error "No Oracle Tcl package available" + return -code error "No Oracle Tcl package available" } eval configure $args - if {[lempty $db]} { - if {[lempty $user]} { - set user $::env(USER) - } - set db $user + if {[::rivet::lempty $db]} { + if {[::rivet::lempty $user]} { + set user $::env(USER) + } + set db $user } } @@ -44,16 +44,16 @@ namespace eval DIO { method open {} { set command "::oralogon" - if {![lempty $user]} { append command " $user" } - if {![lempty $pass]} { append command "/$pass" } - if {![lempty $host]} { append command "@$host" } - if {![lempty $port]} { append command -port $port } + if {![::rivet::lempty $user]} { append command " $user" } + if {![::rivet::lempty $pass]} { append command "/$pass" } + if {![::rivet::lempty $host]} { append command "@$host" } + if {![::rivet::lempty $port]} { append command -port $port } if {[catch $command error]} { return -code error $error } set conn $error - if {![lempty $db]} { + if {![::rivet::lempty $db]} { # ??? mysqluse $conn $db } } @@ -71,17 +71,17 @@ namespace eval DIO { set cmd ::orasql set is_select 0 if {[::string tolower [lindex $req 0]] == "select"} { - set cmd ::orasql - set is_select 1 + set cmd ::orasql + set is_select 1 } set errorinfo "" #puts "ORA:$is_select:$req:<br>" if {[catch {$cmd $_cur $req} error]} { #puts "ORA:error:$error:<br>" - set errorinfo $error - catch {::oraclose $_cur} - set obj [result $interface -error 1 -errorinfo [::list $error]] - return $obj + set errorinfo $error + catch {::oraclose $_cur} + set obj [result $interface -error 1 -errorinfo [::list $error]] + return $obj } if {[catch {::oracols $_cur name} fields]} { set fields "" } ::oracommit $conn @@ -116,7 +116,7 @@ namespace eval DIO { method sql_limit_syntax {limit {offset ""}} { # temporary return "" - if {[lempty $offset]} { + if {[::rivet::lempty $offset]} { return " LIMIT $limit" } return " LIMIT [expr $offset - 1],$limit" diff --git a/rivet/packages/dio/dio_Postgresql.tcl b/rivet/packages/dio/dio_Postgresql.tcl index 5942459..afeec1b 100644 --- a/rivet/packages/dio/dio_Postgresql.tcl +++ b/rivet/packages/dio/dio_Postgresql.tcl @@ -48,13 +48,13 @@ namespace eval DIO { set command "pg_connect" set info "" - if {![lempty $user]} { append info " user=$user" } - if {![lempty $pass]} { append info " password=$pass" } - if {![lempty $host]} { append info " host=$host" } - if {![lempty $port]} { append info " port=$port" } - if {![lempty $db]} { append info " dbname=$db" } + if {![::rivet::lempty $user]} { append info " user=$user" } + if {![::rivet::lempty $pass]} { append info " password=$pass" } + if {![::rivet::lempty $host]} { append info " host=$host" } + if {![::rivet::lempty $port]} { append info " port=$port" } + if {![::rivet::lempty $db]} { append info " dbname=$db" } - if {![lempty $info]} { append command " -conninfo [::list $info]" } + if {![::rivet::lempty $info]} { append command " -conninfo [::list $info]" } if {[catch $command error]} { return -code error $error } @@ -89,7 +89,7 @@ namespace eval DIO { method sql_limit_syntax {limit {offset ""}} { set sql " LIMIT $limit" - if {![lempty $offset]} { append sql " OFFSET $offset" } + if {![::rivet::lempty $offset]} { append sql " OFFSET $offset" } return $sql } @@ -183,7 +183,7 @@ namespace eval DIO { constructor {args} { eval configure $args - if {[lempty $resultid]} { + if {[::rivet::lempty $resultid]} { return -code error "No resultid specified while creating result" } diff --git a/rivet/packages/dio/dio_Sqlite.tcl b/rivet/packages/dio/dio_Sqlite.tcl index 7bdeb92..d5949a1 100644 --- a/rivet/packages/dio/dio_Sqlite.tcl +++ b/rivet/packages/dio/dio_Sqlite.tcl @@ -88,7 +88,7 @@ namespace eval DIO { method sql_limit_syntax {limit {offset ""}} { set sql " LIMIT $limit" - if {![lempty $offset]} { append sql " OFFSET $offset" } + if {![::rivet::lempty $offset]} { append sql " OFFSET $offset" } return $sql } diff --git a/rivet/packages/dio/diodisplay.tcl b/rivet/packages/dio/diodisplay.tcl index e718025..03380d5 100644 --- a/rivet/packages/dio/diodisplay.tcl +++ b/rivet/packages/dio/diodisplay.tcl @@ -30,18 +30,18 @@ catch { ::itcl::delete class DIODisplay } eval configure $args load_response - if {[lempty $DIO]} { + if {[::rivet::lempty $DIO]} { return -code error "You must specify a DIO object" } - if {[lempty $form]} { + if {[::rivet::lempty $form]} { set form [namespace which [::form #auto -defaults response]] } set document [env DOCUMENT_NAME] if {[info exists response(num)] \ - && ![lempty $response(num)]} { + && ![::rivet::lempty $response(num)]} { set pagesize $response(num) } @@ -61,7 +61,7 @@ catch { ::itcl::delete class DIODisplay } # set and fetch one of the object's variables # method configvar {varName string} { - if {[lempty $string]} { return [set $varName] } + if {[::rivet::lempty $string]} { return [set $varName] } configure -$varName $string } @@ -108,7 +108,7 @@ catch { ::itcl::delete class DIODisplay } # recognize CSS info and emit it in appropriate places # method read_css_file {} { - if {[lempty $css]} { return } + if {[::rivet::lempty $css]} { return } if {[catch {open [virtual_filename $css]} fp]} { return } set contents [read $fp] close $fp @@ -205,7 +205,7 @@ catch { ::itcl::delete class DIODisplay } } # if there is a style sheet defined, emit HTML to reference it - if {![lempty $css]} { + if {![::rivet::lempty $css]} { puts "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$css\">" } @@ -274,14 +274,14 @@ catch { ::itcl::delete class DIODisplay } puts "<TABLE>" puts "<TR>" puts "<TD>" - if {![lempty $save]} { + if {![::rivet::lempty $save]} { $form image save -src $save -class DIOFormSaveButton } else { $form submit save.x -value "Save" -class DIOFormSaveButton } puts "</TD>" puts "<TD>" - if {![lempty $cancel]} { + if {![::rivet::lempty $cancel]} { $form image cancel -src $cancel -class DIOFormSaveButton } else { $form submit cancel.x -value "Cancel" -class DIOFormCancelButton @@ -437,7 +437,7 @@ catch { ::itcl::delete class DIODisplay } method rowheader {{total 0}} { set fieldList $fields - if {![lempty $rowfields]} { set fieldList $rowfields } + if {![::rivet::lempty $rowfields]} { set fieldList $rowfields } set rowcount 0 @@ -452,7 +452,7 @@ catch { ::itcl::delete class DIODisplay } set sorting $allowsort ## If sorting is turned off, or this field is not in the ## sortfields, we don't display the sort option. - if {$sorting && ![lempty $sortfields]} { + if {$sorting && ![::rivet::lempty $sortfields]} { if {[lsearch $sortfields $field] < 0} { set sorting 0 } @@ -482,7 +482,7 @@ catch { ::itcl::delete class DIODisplay } puts "<TH CLASS=\"$class\">$html</TH>" } - if {![lempty $rowfunctions] && "$rowfunctions" != "-"} { + if {![::rivet::lempty $rowfunctions] && "$rowfunctions" != "-"} { puts {<TH CLASS="DIORowHeaderFunctions">Functions</TH>} } puts "</TR>" @@ -496,7 +496,7 @@ catch { ::itcl::delete class DIODisplay } if {$alternaterows && ![expr $rowcount % 2]} { set alt Alt } set fieldList $fields - if {![lempty $rowfields]} { set fieldList $rowfields } + if {![::rivet::lempty $rowfields]} { set fieldList $rowfields } puts "<TR>" foreach field $fieldList { @@ -514,7 +514,7 @@ catch { ::itcl::delete class DIODisplay } puts "<TD CLASS=\"$class\">$text</TD>" } - if {![lempty $rowfunctions] && "$rowfunctions" != "-"} { + if {![::rivet::lempty $rowfunctions] && "$rowfunctions" != "-"} { set f [::form #auto] puts "<TD NOWRAP CLASS=\"DIORowFunctions$alt\">" $f start @@ -556,7 +556,7 @@ catch { ::itcl::delete class DIODisplay } set class DIODisplayField if {[info exists data(type)]} { - if {![lempty [::itcl::find classes *DIODisplayField_$data(type)]]} { + if {![::rivet::lempty [::itcl::find classes *DIODisplayField_$data(type)]]} { set class DIODisplayField_$data(type) } @@ -570,7 +570,7 @@ catch { ::itcl::delete class DIODisplay } upvar 1 $arrayName $arrayName set result [$DIO fetch $key $arrayName] set error [$DIO errorinfo] - if {![lempty $error]} { return -code error $error } + if {![::rivet::lempty $error]} { return -code error $error } return $result } @@ -578,7 +578,7 @@ catch { ::itcl::delete class DIODisplay } upvar 1 $arrayName array set result [$DIO store array] set error [$DIO errorinfo] - if {![lempty $error]} { return -code error $error } + if {![::rivet::lempty $error]} { return -code error $error } return $result } @@ -586,14 +586,14 @@ catch { ::itcl::delete class DIODisplay } upvar 1 $arrayName array set result [$DIO update_with_explicit_key $key array] set error [$DIO errorinfo] - if {![lempty $error]} {return -code error $error} + if {![::rivet::lempty $error]} {return -code error $error} return $result } method delete {key} { set result [$DIO delete $key] set error [$DIO errorinfo] - if {![lempty $error]} { return -code error $error } + if {![::rivet::lempty $error]} { return -code error $error } return $result } @@ -702,7 +702,7 @@ catch { ::itcl::delete class DIODisplay } } set useFields $fields - if {![lempty $searchfields]} { set useFields $searchfields } + if {![::rivet::lempty $searchfields]} { set useFields $searchfields } $form select by -values [pretty_fields $useFields] \ -class DIOMainSearchBy @@ -727,7 +727,7 @@ catch { ::itcl::delete class DIODisplay } } puts "</TD></TR>" - if {![lempty $numresults]} { + if {![::rivet::lempty $numresults]} { puts "<TR><TD CLASS=DIOForm>Results per page: " $form select num -values $numresults -class DIOMainNumResults puts "</TD></TR>" @@ -738,11 +738,11 @@ catch { ::itcl::delete class DIODisplay } } method sql_order_by_syntax {} { - if {[info exists response(sort)] && ![lempty $response(sort)]} { + if {[info exists response(sort)] && ![::rivet::lempty $response(sort)]} { return " ORDER BY $response(sort)" } - if {![lempty $defaultsortfield]} { + if {![::rivet::lempty $defaultsortfield]} { return " ORDER BY $defaultsortfield" } } @@ -912,7 +912,7 @@ catch { ::itcl::delete class DIODisplay } ### method fields {{list ""}} { - if {[lempty $list]} { return $fields } + if {[::rivet::lempty $list]} { return $fields } foreach field $list { if {[lsearch $allfields $field] < 0} { return -code error "Field $field does not exist." @@ -922,7 +922,7 @@ catch { ::itcl::delete class DIODisplay } } method searchfields {{list ""}} { - if {[lempty $list]} { return $searchfields } + if {[::rivet::lempty $list]} { return $searchfields } foreach field $list { if {[lsearch $allfields $field] < 0} { return -code error "Field $field does not exist." @@ -932,7 +932,7 @@ catch { ::itcl::delete class DIODisplay } } method rowfields {{list ""}} { - if {[lempty $list]} { return $rowfields } + if {[::rivet::lempty $list]} { return $rowfields } foreach field $list { if {[lsearch $allfields $field] < 0} { return -code error "Field $field does not exist." @@ -1002,7 +1002,7 @@ catch { ::itcl::delete class DIODisplay } public variable confirmdelete 1 public variable css "diodisplay.css" { - if {![lempty $css]} { + if {![::rivet::lempty $css]} { catch {unset cssArray} read_css_file } @@ -1067,7 +1067,7 @@ catch { ::itcl::delete class ::DIODisplayField } # if text (field description) isn't set, prettify the actual # field name and use that - if {[lempty $text]} { set text [pretty [split $name _]] } + if {[::rivet::lempty $text]} { set text [pretty [split $name _]] } } destructor { @@ -1118,7 +1118,7 @@ catch { ::itcl::delete class ::DIODisplayField } } method configvar {varName string} { - if {[lempty $string]} { return [set $varName] } + if {[::rivet::lempty $string]} { return [set $varName] } configure -$varName $string } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@tcl.apache.org For additional commands, e-mail: commits-h...@tcl.apache.org