xowiki::FormPage proc fetch_object (public)

 xowiki::FormPage[i] fetch_object -item_id item_id  \
    [ -revision_id revision_id ] -object object  \
    [ -initialize on|off ]

Defined in packages/xowiki/tcl/xowiki-procs.tcl

Load a content item into the specified object. If revision_id is provided, the specified revision is returned, otherwise the live revision of the item_id. If the object does not exist, we create it.

Switches:
-item_id
(required)
-revision_id
(defaults to "0") (optional)
-object
(required)
-initialize
(boolean) (defaults to "true") (optional)
Returns:
cr item object

Partial Call Graph (max 5 caller/called nodes):
%3 test_link_tests link_tests (test xowiki) xowiki::FormPage proc fetch_object xowiki::FormPage proc fetch_object test_link_tests->xowiki::FormPage proc fetch_object test_path_resolve path_resolve (test xowiki) test_path_resolve->xowiki::FormPage proc fetch_object test_xowiki_test_cases xowiki_test_cases (test xowiki) test_xowiki_test_cases->xowiki::FormPage proc fetch_object db_exec db_exec (public) xowiki::FormPage proc fetch_object->db_exec db_with_handle db_with_handle (public) xowiki::FormPage proc fetch_object->db_with_handle

Testcases:
xowiki_test_cases, link_tests, path_resolve
Source code:
#ns_log notice "=== fetch_object $item_id"
#
# We handle here just loading object instances via item_id, since
# only live_revisions are kept in xowiki_form_instance_item_index.
# The loading via revision_id happens as before in CrClass.
#
if {$item_id == 0} {
  return [next]
}

if {![nsf::is object $object]} {
  # if the object does not yet exist, we have to create it
  :create $object
}

db_with_handle db {
  set sql [::xo::dc prepare -handle $db -argtypes integer {
    select * from xowiki_form_instance_item_view where item_id = :item_id
  }]
  set selection [db_exec 0or1row $db dbqd..Formpage-fetch_object $sql]
}

if {$selection eq ""} {
  error [subst {
    The form page with item_id $item_id was not found in the
    xowiki_form_instance_item_index.  Consider 'DROP TABLE
    xowiki_form_instance_item_index CASCADE;' and restart server
    (the table is rebuilt automatically, but this could take a
    while, when the number of pages is huge).
  }]
}

$object mset [ns_set array $selection]

if {$initialize} {
  $object initialize_loaded_object
}
return $object
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: