# # The AOLserver front-end to the wftk toolkit (wftk.tcl) is an AOLserver-specific Tcl # extension which organizes repository and object interactions in a convenient way. # More information is at http://www.vivtek.com/wftk/doc/code/aolserver/wftk/ # # Copyright (c) 2004-2005, Vivtek. # # This program 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. # # This program 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ns_log notice "Registering wftk basic front-end v0.1 (c) 2004-2005, Vivtek. http://www.vivtek.com/wftk.html for more info." |
See URL handlers for general-purpose repository interface |
nsv_set wftk handle 0 nsv_set wftk handles [list] nsv_set wftk critsec [ns_critsec create] |
set handle wftk[nsv_incr wftk handle] nsv_lappend wftk handles $handle return $handle |
set handle [lindex $args 0]
xml free $handle
ns_critsec enter [nsv_get wftk critsec]
set handles [nsv_get wftk handles]
set i [lsearch -exact $handles $handle]
if {$i >= 0} {
nsv_set wftk handles [lreplace $handles $i $i]
}
ns_critsec leave [nsv_get wftk critsec]
return OK
|
set reposloc [lindex $args 0]
if {[lsearch [nsv_get wftk handles] $reposloc] > -1} { return $reposloc }
if [nsv_exists wftk_repositories $reposloc] { set reposloc [nsv_get wftk_repositories $reposloc] }
if [nsv_exists wftk repos($reposloc)] {
set handle [nsv_get wftk repos($reposloc)]
if {[lsearch [nsv_get wftk handles] $handle] > -1} {
return $handle
}
}
set handle [wftk gethandle]
set r [open $reposloc r]
xml parse $handle [read $r]
close $r
xml set $handle basedir [file dirname $reposloc]/
repmgr open $handle
nsv_set wftk repos($reposloc) $handle
return $handle
|
if {[llength $args] < 1} { error "no repository given" "wftk list" }
if {[llength $args] < 2} {
return [repmgr list $repos]
} else {
return [repmgr list $repos [lindex $args 1]]
}
|
set handle [wftk gethandle] xml parse $handle "<list id=\"[lindex $args 1]\"/>" repmgr list $repos [lindex $args 1] $handle return $handle |
set handle [wftk gethandle] repmgr defn $repos $handle [lindex $args 1] return $handle |
set obj [eval wftk getxml $args]
if [xml is_element $obj] {
set ret [wftk xml2ns_set $obj]
wftk release $obj
return $ret
} else {
wftk release $obj
return ""
}
|
set hdl [wftk gethandle]
set ret [ns_set create]
for {xml firstelem $hdl [lindex $args 0]} {[xml is_element $hdl]} {xml nextelem $hdl $hdl} {
if [xml is $hdl field] {
ns_set put $ret [xml attrval $hdl id] [xml stringcontenthtml $hdl]
}
}
wftk release $hdl
return $ret
|
set handle [wftk gethandle] repmgr get $repos $handle [lindex $args 1] [lindex $args 2] return $handle |
set handle [wftk ns_set2xml [lindex $args 2]] set ret [wftk addxml $repos [lindex $args 1] $handle] wftk release $handle return $ret |
set handle [wftk gethandle]
xml create $handle record
set size [ns_set size [lindex $args 0]]
for {set i 0} {$i < $size} {incr i} {
xmlobj set $handle "" [ns_set key [lindex $args 0] $i] [ns_set value [lindex $args 0] $i]
}
return $handle
|
return [repmgr add $repos [lindex $args 1] [lindex $args 2]] |
set handle [wftk ns_set2xml [lindex $args 2]] set ret [repmgr merge $repos [lindex $args 1] $handle [lindex $args 3]] wftk release $handle return $ret |
return [repmgr mod $repos [lindex $args 1] [lindex $args 2] [lindex $args 3]] |
return [repmgr del $repos [lindex $args 1] [lindex $args 2]] |
while {[llength $args] < 7} { lappend args "" }
set obj [lindex $args 3]
set release_obj 0
if [catch {
set obj [wftk ns_set2xml $obj]
set release_obj 1
} result] {
ns_log notice "?? $result"
}
# list key notification to subject
set ret [repmgr notify $repos [lindex $args 1] [lindex $args 2] $obj [lindex $args 4] [lindex $args 5] [lindex $args 6]]
if {$release_obj} { wftk release $obj }
return $ret
|
wftk submit my_repos tracking_reports -fld title "This is our title" $bodyThe default is to attach the value of $body as the document. If the attachment is in a file, we use the alternative form
wftk submit my_repos tracking_reports $fields -file $filename
set offset 2
if {![string compare [lindex $args $offset] -xml]} {
set extras ""
incr offset
set xml_extras [lindex $args $offset]
incr offset
} elseif {[string compare [lindex $args $offset] -fld]} {
set extras [lindex $args $offset]
incr offset
} else {
set extras [ns_set create]
while {![string compare [lindex $args $offset] -fld]} {
incr offset
ns_set put $extras [lindex $args $offset] [lindex $args [expr $offset + 1]]
incr offset
incr offset
}
}
set command submit
if {![string compare [lindex $args $offset] -file]} {
incr offset
set command store
}
if {$extras == ""} {
return [repmgr $command $repos [lindex $args 1] $xml_extras [lindex $args $offset]]
}
set handle [wftk ns_set2xml $extras]
set ret [repmgr $command $repos [lindex $args 1] $handle [lindex $args $offset]]
wftk release $handle
return $ret
|
| This code and documentation are released under the terms of the GNU license. They are copyright (c) 2003-2005, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license. This presentation was prepared with LPML. Try literate programming. You'll like it. |