Index: openacs-4/packages/cronjob/cronjob.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cronjob/cronjob.info,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/packages/cronjob/cronjob.info 23 Sep 2002 23:32:14 -0000 1.3 +++ openacs-4/packages/cronjob/cronjob.info 9 Oct 2002 00:26:21 -0000 1.3.2.1 @@ -20,12 +20,13 @@ - + + @@ -42,9 +43,9 @@ - - + + Index: openacs-4/packages/cronjob/tcl/cronjob-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cronjob/tcl/cronjob-init.tcl,v diff -u -r1.2 -r1.2.4.1 --- openacs-4/packages/cronjob/tcl/cronjob-init.tcl 24 Dec 2001 02:50:17 -0000 1.2 +++ openacs-4/packages/cronjob/tcl/cronjob-init.tcl 9 Oct 2002 00:26:21 -0000 1.2.4.1 @@ -11,178 +11,174 @@ ad_schedule_proc -thread t 60 cronjob_check if {![info exists qd_write_query_select]} { - -ad_proc qd_write_query_select {package attrs} { + + ad_proc qd_write_query_select {package attrs} { -

Returns Postgresql function with: -

+

Returns Postgresql function with: +

-} { - ns_log Debug "Running qd_write_query_select with $package $attrs" + } { + ns_log Debug "Running qd_write_query_select with $package $attrs" set query [list] - set in_args [list] + set in_args [list] set args [concat $attrs] foreach {attr sign value} $args { - lappend in_args $attr - set attr_array($attr) $value + lappend in_args $attr + set attr_array($attr) $value } set attrs_and_defaults [eval qd_choose_function $package $in_args] foreach {attr default_value} $attrs_and_defaults { - # see if attr was passed in with value - if {![info exists attr_array($attr)]} { - - if {[string match "" $default_value]} { - ns_log Debug "Attempt to call $package with no value for $attr" - return -code error - } - lappend query $default_value - } else { - lappend query "$attr_array($attr)" - } + # see if attr was passed in with value + if {![info exists attr_array($attr)]} { + + if {[string match "" $default_value]} { + ns_log Debug "Attempt to call $package with no value for $attr" + return -code error + } + lappend query $default_value + } else { + lappend query "$attr_array($attr)" + } } ns_log Debug "${package}([join $query ",\n"]);" return "${package}([join $query ",\n"]);" -} + } -ad_proc qd_add_package {package args} { -

Adds a package with all the attributes for every function of the same name. -

For example, if you have two functions that could be called - foo(a,b,c) and foo(a,c,d), - the package would be registered using: -

-
-         qd_add_package foo a b c d
-       
-
+ ad_proc qd_add_package {package args} { +

Adds a package with all the attributes for every function of the same name. +

For example, if you have two functions that could be called + foo(a,b,c) and foo(a,c,d), + the package would be registered using: +

+
+	qd_add_package foo a b c d
+	
+
-} { + } { nsv_set qd_pg_packages $package $args set n 1 foreach attr $args { - nsv_set $package $attr $n - set n [expr $n * 2] + nsv_set $package $attr $n + set n [expr $n * 2] } -} + } -ad_proc qd_total_attributes {package attributes} { + ad_proc qd_total_attributes {package attributes} { -

Totals the attribute values. -} { +

Totals the attribute values. + } { upvar $package package_array upvar $attributes attrs set total 0 foreach attribute $attrs { - incr total $package_array($attribute) - ns_log Debug "Adding $package_array($attribute) $total" + incr total $package_array($attribute) + ns_log Debug "Adding $package_array($attribute) $total" } return $total -} + } -ad_proc qd_add_function {package args} { + ad_proc qd_add_function {package args} { -

Adds a single function, including defaults to a package. -

If one foo function has three attributes: a, b and c, where - a is required and b can be null and c default to 't', +

Adds a single function, including defaults to a package. +

If one foo function has three attributes: a, b and c, where + a is required and b can be null and c default to 't', the function would be - registered using: -

-
-       qd_add_function foo a "" b "null" c "'t'"
-    
-
+ registered using: +
+
+	qd_add_function foo a "" b "null" c "'t'"
+	
+
-} { + } { # total up the function value. array set temp_package [nsv_array get $package] set i 1 foreach {attr default} $args { - lappend attr_list $attr + lappend attr_list $attr } set total [qd_total_attributes temp_package attr_list] nsv_set ${package}_functions $total $args -} + } -ad_proc qd_choose_function {package args} { + ad_proc qd_choose_function {package args} { -

Used to choose a function based on passed in attributes. +

Used to choose a function based on passed in attributes. -} { + } { array set temp_package [nsv_array get $package] set total [qd_total_attributes temp_package args] - if {[nsv_exists ${package}_functions $total]} { - ns_log Debug "Found matching sig: '$total'" - return [nsv_get ${package}_functions $total] + if {[nsv_exists ${package}_functions $total]} { + ns_log Debug "Found matching sig: '$total'" + return [nsv_get ${package}_functions $total] } set functions [nsv_array names ${package}_functions] foreach sig $functions { - ns_log Debug "checking sig '$total' against '$sig'" - if {$total == [expr $sig & $total]} { - ns_log Debug "Found match '$total' in '$sig'" - return [nsv_get ${package}_functions $sig] - } + ns_log Debug "checking sig '$total' against '$sig'" + if {$total == [expr $sig & $total]} { + ns_log Debug "Found match '$total' in '$sig'" + return [nsv_get ${package}_functions $sig] + } } return "!NO MATCH: $total not in $functions" -} + } -proc qd_write_query {package args} { + proc qd_write_query {package args} { set query [list] set attrs_and_defaults [eval qd_choose_function $package $args] foreach {attr default_value} $attrs_and_defaults { - if {[lsearch $args $attr] < 0 } { - if {[string match "" $default_value]} { - ns_log Debug "Attempt to call $package with no value for $attr" - return -code error - } - lappend query $default_value - } else { - lappend query ":${attr}" - } + if {[lsearch $args $attr] < 0 } { + if {[string match "" $default_value]} { + ns_log Debug "Attempt to call $package with no value for $attr" + return -code error + } + lappend query $default_value + } else { + lappend query ":${attr}" + } } return [join $query ",\n"] -} + } -proc qd_write_query_upvar {package listvar} { + proc qd_write_query_upvar {package listvar} { set query [list] upvar $listvar args set attrs_and_defaults [eval qd_choose_function $package $args] if {[string match "!NO MATCH:*" $attrs_and_defaults ]} { - ns_log Debug "$attrs_and_defaults" - return -code error + ns_log Debug "$attrs_and_defaults" + return -code error } foreach {attr default_value} $attrs_and_defaults { - if {[lsearch $args $attr] < 0 } { - if {[string match "" $default_value]} { - ns_log Debug "Attempt to call $package with no value for $attr" - return -code error - } - lappend query $default_value - } else { - lappend query ":${attr}" - } + if {[lsearch $args $attr] < 0 } { + if {[string match "" $default_value]} { + ns_log Debug "Attempt to call $package with no value for $attr" + return -code error + } + lappend query $default_value + } else { + lappend query ":${attr}" + } } return [join $query ",\n"] -} + } - - - } qd_add_package cronjob__new cronjob_id user_id description approved_p disabled_p minute hr mon day dayofweek run_sql run_tcl email creation_user creation_ip context_id qd_add_function cronjob__new "cronjob_id" "null" "user_id" "" "description" "" "approved_p" "'f'" "disabled_p" "'f'" "minute" "'0'" "hr" "'0'" "mon" "'0'" "day" "'0'" "dayofweek" "'0'" "run_sql" "" "run_tcl" "" "email" "" "creation_user" "null" "creation_ip" "null" "context_id" "null" - qd_add_package cronjob__set_attrs "cronjob_id" "user_id" "description" "approved_p" "disabled_p" "minute" "hr" "mon" "day" "dayofweek" "run_sql" "run_tcl" "email" qd_add_function cronjob__set_attrs "cronjob_id" "" "user_id" "null" "description" "null" "approved_p" "null" "disabled_p" "'f'" "minute" "null" "hr" "null" "mon" "null" "day" "null" "dayofweek" "null" "run_sql" "null" "run_tcl" "null" "email" "null" Index: openacs-4/packages/cronjob/tcl/cronjob-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cronjob/tcl/cronjob-procs.tcl,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/packages/cronjob/tcl/cronjob-procs.tcl 12 Sep 2002 22:44:25 -0000 1.4 +++ openacs-4/packages/cronjob/tcl/cronjob-procs.tcl 9 Oct 2002 00:26:21 -0000 1.4.2.1 @@ -13,33 +13,18 @@ } { - # setup the vars - set time [ns_time] - set minute [ns_fmttime $time %M] - set hr [ns_fmttime $time %H] - set mon [ns_fmttime $time %m] + # setup the vars + set time [ns_time] + set minute [ns_fmttime $time %M] + set hr [ns_fmttime $time %H] + set mon [ns_fmttime $time %m] set day [ns_fmttime $time %d] set dayofweek [ns_fmttime $time %w] - set sql " -select - cronjob_id -from - cronjobs -where - disabled_p = 'f' AND - approved_p = 't' AND - ((minute = :minute) OR (minute = '*')) AND - ((hr = :hr ) OR (hr = '*')) AND - ((mon = :mon ) OR (mon = '*')) AND - ((day = :day ) OR (day = '*')) AND - ((dayofweek = :dayofweek ) OR (dayofweek = '*'))" - - db_foreach cronjob_sched_foreach $sql { + db_foreach cronjob_sched_foreach "" { + ad_schedule_proc -once t -thread t 1 cronjob_run $cronjob_id + } - ad_schedule_proc -once t -thread t 1 cronjob_run $cronjob_id - } - } @@ -48,57 +33,47 @@ Proc to run cronjobs } { - set table "No SQL" - set sql " -select - description, - run_sql, - run_tcl, - email -from - cronjobs -where - cronjob_id = :cronjob_id" - ns_log Notice "Cronjob_id is $cronjob_id" - db_1row "crontab_query" $sql - db_release_unused_handles - if {![string match "" $run_sql]} { - set table "" - set db [ns_db gethandle "log"] - set sel [ns_db select $db $run_sql] - set rownum 0 - if {![string match "" $sel]} { - while {[ns_db getrow $db $sel]} { - set size [ns_set size $sel] - if {$rownum == 0} { - for {set i 0 } {$i < $size} {incr i} { - append table "\n" - } - } - append table "" - for {set i 0 } {$i < $size} {incr i} { - append table "\n" - } - append table "" - incr rownum - } - } - append table "
[ns_set key $sel $i]
[ns_set value $sel $i]
" - if {$rownum == 0} { - set table "No Rows Returned" - } - ns_db releasehandle $db + set table "No SQL" + ns_log Notice "Cronjob_id is $cronjob_id" + db_1row crontab_query $sql + db_release_unused_handles + if {![string match "" $run_sql]} { + set table "" + set db [ns_db gethandle "log"] + set sel [ns_db select $db $run_sql] + set rownum 0 + if {![string match "" $sel]} { + while {[ns_db getrow $db $sel]} { + set size [ns_set size $sel] + if {$rownum == 0} { + for {set i 0 } {$i < $size} {incr i} { + append table "\n" + } } + append table "" + for {set i 0 } {$i < $size} {incr i} { + append table "\n" + } + append table "" + incr rownum + } + } + append table "
[ns_set key $sel $i]
[ns_set value $sel $i]
" + if {$rownum == 0} { + set table "No Rows Returned" + } + ns_db releasehandle $db + } - # evaluate the run_tcl code - eval $run_tcl + # evaluate the run_tcl code + eval $run_tcl - if {![string match "" $email]} { - ns_log notice "sending cronjob email to $email" - set headers [ns_set create] - ns_set put $headers "Content-Type" "text/html" - ns_sendmail $email [ad_host_administrator] "Cronjob $cronjob_id" "Description:
$description
$table" $headers - } - return + if {![string match "" $email]} { + ns_log notice "sending cronjob email to $email" + set headers [ns_set create] + ns_set put $headers "Content-Type" "text/html" + ns_sendmail $email [ad_host_administrator] "Cronjob $cronjob_id" "Description:
$description
$table" $headers + } + return } Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/cronjob/tcl/cronjob-procs.xql'. Fisheye: No comparison available. Pass `N' to diff?