xowiki::Page instproc www-autosave-attribute (public)
<instance of xowiki::Page> www-autosave-attribute
Defined in packages/xowiki/tcl/xowiki-www-procs.tcl
The web-callable method which is a simplified version of save-attributes, but which does NOT perform input validation, which might be a problem in case of partial input.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set field_names [:field_names] #ns_log notice "[self] autosave-attribute called field-names: $field_names" set provided_form_parameters [xo::cc get_all_form_parameter] set keys [dict keys $provided_form_parameters] if {[llength $keys] == 1} { set key [lindex $keys 0] set value [::xo::cc form_parameter $key] ns_log notice "[self] autosave-attribute save '$key' <$value>" set prefix "" regexp {^([^.]+)[.]} $key . prefix if {$prefix ne "" && $prefix in $field_names} { # # We are inside a compound field, which is saved in the instance # attributes. # #ns_log notice "SAVE old ia <${:instance_attributes}>" if {[dict exists ${:instance_attributes} $prefix]} { set innerDict [dict get ${:instance_attributes} $prefix] } else { set innerDict "" } dict set innerDict $key $value dict set :instance_attributes $prefix $innerDict #ns_log notice "SAVE new ia <${:instance_attributes}>" set s [:find_slot instance_attributes] :update_attribute_from_slot $s ${:instance_attributes} ns_return 200 text/plain ok } elseif {$prefix eq "" && $key in $field_names} { # # It is a plain attribute, either from the cr-attributes # (starting with an "_") or from the instance attributes. # if {[string match _* $key]} { set s [:find_slot [string range $key 1 end]] :update_attribute_from_slot $s $value } else { set s [:find_slot instance_attributes] dict set :instance_attributes $key $value :update_attribute_from_slot $s ${:instance_attributes} } ns_return 200 text/plain ok } else { ns_return 404 text/plain "not ok" ns_log error "autosave attribute: unexpected field name <$key>" "(prefix '$prefix'), not contained in <$field_names> " "value [llength $value] bytes" } } else { ns_log warning "autosave attribute: expecting a single form parameter with a prefix keys <$keys>" ns_return 404 text/plain "not ok" } ns_log notice "SAVE-att DONE" ad_script_abortXQL Not present: Generic, PostgreSQL, Oracle