xowiki::Package instproc lookup (public)
<instance of xowiki::Package> lookup \ [ -use_package_path use_package_path ] \ [ -use_site_wide_pages use_site_wide_pages ] \ [ -default_lang default_lang ] -name name \ [ -parent_id parent_id ]
Defined in /var/www/openacs.org/packages/xowiki/tcl/package-procs.tcl
Lookup name (with maybe cross-package references) from a given parent_id or from the list of configured instances (obtained via package_path).
- Switches:
- -use_package_path (optional, defaults to
"true"
)- -use_site_wide_pages (optional, defaults to
"false"
)- -default_lang (optional)
- -name (required)
- -parent_id (optional)
- Testcases:
- path_resolve
Source code: #:log "LOOKUP of <$name> on-package: ${:id} parent_id '$parent_id'" set pkg_info [:get_package_id_from_page_name -default_lang $default_lang $name] if {[dict exists $pkg_info package_id]} { set package_id [dict get $pkg_info package_id] } else { return 0 } if {$parent_id eq ""} { set parent_id [::$package_id folder_id] } set item_id [::xo::db::CrClass lookup -name [dict get $pkg_info page_name] -parent_id $parent_id] #:log "[dict get $pkg_info page_name] $parent_id in package $package_id returns $item_id, parent_id $parent_id" # # Test for "0" is only needed when we want to create the first # root folder. # if {$item_id == 0 && $parent_id != 0} { # # Page not found so far, get the parent page. # set p [::xo::db::CrClass get_instance_from_db -item_id $parent_id] # # Is the parent-page a regular page and a folder-link? # If so, de-reference the link. # if {[$p istype ::xowiki::FormPage] && [$p is_link_page] && [$p is_folder_page]} { set target [$p get_target_from_link_page] set target_package_id [$target package_id] set target_item_id [$target item_id] #:log "SYMLINK LOOKUP from target-package $target_package_id source package $package_id name $name" # # Avoid potential recursive loop # if {${:id} != $target_package_id || $parent_id != $target_item_id} { set target_item_id [::$target_package_id lookup -use_package_path $use_package_path -use_site_wide_pages $use_site_wide_pages -default_lang $default_lang -name $name -parent_id $target_item_id] } else { :log "SYMLINK LOOKUP avoid recursive loop name $name package_id ${:id} parent_id [$target item_id]" set target_item_id 0 } if {$target_item_id != 0} { #:msg "SYMLINK FIX $target_item_id set_resolve_context -package_id ${:id} -parent_id $parent_id" ::xo::db::CrClass get_instance_from_db -item_id $target_item_id ::$target_item_id set_resolve_context -package_id ${:id} -parent_id $parent_id } return $target_item_id } } if {$item_id == 0 && $use_package_path} { # # Page not found so far. Is the page inherited along the package # path? # foreach package [:package_path] { set item_id [$package lookup -name $name] #:msg "lookup from package $package $name returns $item_id" if {$item_id != 0} break } } if {$item_id == 0 && $use_site_wide_pages} { # # Page not found so far. Is the page a site_wide page? # foreach pkgClass [${:id} info precedence] { if {[$pkgClass istype ::xo::PackageMgr] && [$pkgClass package_key] ne "apm_package"} { set item_id [$pkgClass lookup_side_wide_page -name $name] #ns_log notice "SITE_WIDE: [list $pkgClass lookup_side_wide_page -name $name] -> $item_id" if {$item_id ne 0} { break } } } } return $item_idXQL Not present: Generic, PostgreSQL, Oracle