Index: openacs-4/packages/xowf/tcl/atjob-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/tcl/atjob-procs.tcl,v diff -u -r1.8.2.7 -r1.8.2.8 --- openacs-4/packages/xowf/tcl/atjob-procs.tcl 1 Jul 2020 19:31:58 -0000 1.8.2.7 +++ openacs-4/packages/xowf/tcl/atjob-procs.tcl 8 Dec 2020 15:36:54 -0000 1.8.2.8 @@ -16,6 +16,7 @@ ::xo::Attribute create cmd ::xo::Attribute create time ::xo::Attribute create object + ::xo::Attribute create url ::xo::Attribute create priority -default 5 } @@ -54,7 +55,12 @@ if {$form_id != 0} { ::xo::db::CrClass get_instance_from_db -item_id $form_id set instance_attributes [dict merge [::$form_id default_instance_attributes] [list cmd ${:cmd}]] - set name [::xowiki::autoname new -name [::$form_id name] -parent_id $owner_id] + if {[info exists :url]} { + dict set instance_attributes url ${:url} + } + set name [::xowiki::autoname new \ + -name [::$form_id name] \ + -parent_id $owner_id] set f [::xowiki::FormPage new -destroy_on_cleanup \ -package_id $package_id \ -parent_id $owner_id \ @@ -86,7 +92,7 @@ } atjob proc run_jobs {item_ids} { - #:log "---run xowf jobs START" + :log "--at run jobs START" set sql "select package_id, item_id, name, parent_id, publish_status, creation_user, revision_id, page_template, instance_attributes @@ -95,7 +101,8 @@ set items [::xowiki::FormPage instantiate_objects \ -object_class ::xowiki::FormPage \ - -sql $sql] + -sql $sql \ + -initialize false] if {[llength [$items children]] > 0} { @@ -105,30 +112,45 @@ #:log "--at *** job=[$item serialize] ***\n" set owner_id [$item parent_id] set party_id [$item creation_user] + set package_id [$item package_id] set __ia [$item instance_attributes] + if {![dict exists $__ia cmd]} { #ns_log notice "--at ignore strange entry [$item serialize]" ns_log notice "--at ignore strange entry, no cmd in [$item instance_attributes]" continue } set cmd [dict get $__ia cmd] + if {[dict exists $__ia url]} { + set url [dict get $__ia url] + if {$url eq ""} { + set url [lindex [site_node::get_url_from_object_id -object_id $package_id] 0] + ns_log warning "--at providing best effort url, since no valid URL was provided by caller (cmd $cmd)" + } + } + # - # Probably, we should add a URL to the form to get better - # conformance for atjobs. + # Initialize the package with the provided url and user_id. # - ::xo::ConnectionContext require -url / - - # We assume, the owner object is a cr-item + ::xo::Package initialize \ + -package_id $package_id \ + -url $url \ + -user_id $party_id + # + # We require that the owner object is at least a cr-item + # ::xo::db::CrClass get_instance_from_db -item_id $owner_id + # + # We require that the package is from the xowiki family; make + # sure, the url looks like real + # + #::xo::Package initialize \ + # -package_id [::$owner_id package_id] \ + # -user_id $party_id \ + # -init_url 0 -actual_query "" + #::$package_id set_url -url [::$package_id package_url][::$owner_id name] - # We assume, the package is from the xowiki family; make sure, the url looks like real - ::xo::Package initialize \ - -package_id [::$owner_id package_id] \ - -user_id $party_id \ - -init_url 0 -actual_query "" - ::$package_id set_url -url [::$package_id package_url][::$owner_id name] - :log "--at executing atjob $cmd" ad_try { $owner_id {*}$cmd @@ -172,7 +194,9 @@ # set sql "select xi.item_id from xowiki_form_instance_item_index xi, cr_items i2, cr_items i1, cr_revisions cr - where i2.item_id = xi.page_template and i2.content_type = '::xowiki::Form' and i2.name = 'en:atjob-form' + where i2.item_id = xi.page_template + and i2.content_type = '::xowiki::Form' + and i2.name = 'en:atjob-form' and cr.publish_date $op to_timestamp(:ansi_time,'YYYY-MM-DD HH24:MI') and i1.item_id = xi.item_id and cr.revision_id = i1.live_revision Index: openacs-4/packages/xowf/www/prototypes/atjob-form.page =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/www/prototypes/Attic/atjob-form.page,v diff -u -r1.1 -r1.1.6.1 --- openacs-4/packages/xowf/www/prototypes/atjob-form.page 28 Aug 2014 08:24:57 -0000 1.1 +++ openacs-4/packages/xowf/www/prototypes/atjob-form.page 8 Dec 2020 15:36:54 -0000 1.1.6.1 @@ -4,12 +4,13 @@ -title "At-Job Form" \ -set anon_instances t \ -set text {} \ - -set form {{
} text/html} \ + -set form {{} text/html} \ -set form_constraints { _page_order:hidden _creator:hidden _title:text,label=#acs-kernel.common_Title# {_publish_date:date,format=DD_MONTH_YYYY_HH24_MI,label=Scheduled execution time} {_publish_status:radio,options={waiting production} {done expired},label=Status} +{url:text,default=} @table_properties:publish_status=all @table:_name,_publish_status,_last_modified }