- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xo::Package
::xo::Package create ... \
[ -context (default "::xo::cc") ] \
[ -force_refresh_login (default "false") ] \
[ -id:integer id:integer ] \
[ -package_url package_url ] \
[ -url url ]
Defined in
Class Relations
- class: ::xo::PackageMgr
- superclass: ::xo::db::Object
- subclass: ::xo::oauth::Package, ::xowiki::Package
::xo::PackageMgr create ::xo::Package \ -superclass ::xo::db::ObjectMethods (to be applied on instances)
context (setter)
default_locale (setter)
exists_form_parameter (forward)
exists_query_parameter (forward)
force_refresh_login (setter)
form_parameter (forward)
get_parameter (scripted)
# # Get value from package parameter (per-instance) # set value [::parameter::get -package_id ${:id} -parameter $attribute -default $default] if {$value ne $default} { return $value } # # Make a second attempt from the global value. # return [parameter::get_global_value -package_key ${:package_key} -parameter $attribute -default $default]handle_http_caching (scripted)
# # Subpackages can overload this method for realizing # # a) package specific caching policies # b) page-type specific caching policies # c) page specific caching policies # # Items (b) and (c) can e realized via the instance variable of # the package object named "invoke_object", which is set for # non-error cases in e.g. xowiki. # ns_set put [ns_conn outputheaders] "Cache-Control" "max-age=0, no-cache, no-store" #id (setter)
init (scripted)
set id ${:id} set package_url [lindex [site_node::get_url_from_object_id -object_id $id] 0] #:log "--R creating package_url='$package_url'" if {$package_url ne ""} { set info [site_node::get -url $package_url] #set package_url [dict get $info url] :package_key [dict get $info package_key] :instance_name [dict get $info instance_name] } else { ::xo::dc 1row package_info { select package_key, instance_name from apm_packages where package_id = :id } :package_key $package_key :instance_name $instance_name } if {[ns_conn isconnected]} { # in case of host-node map, simplify the URL to avoid redirects # .... but ad_host works only, when we are connected.... # TODO: solution for syndication set root [acs::root_of_host [ad_host]] regexp "^${root}(.*)$" $package_url _ package_url } #:log "--R package_url= $package_url (was $info(url))" :package_url $package_url if {[info exists :url] && [info exists root]} { regexp "^${root}(.*)$" ${:url} _ :url } elseif {![info exists :url]} { #:log "--R we have no url, use package_url '$package_url'" # if we have no more information, we use the package_url as actual URL set :url $package_url } :set_url -url ${:url} set :mime_type text/html set :delivery ns_return set target_class ::${:package_key}::Package if {[:info class] ne $target_class && [:isclass $target_class]} { :class $target_class } # # Save the relation between class and package_key for fast lookup. # set ::xo::package_class(${:package_key}) [:info class] :initializeinitialize (scripted)
<instance of xo::Package> initialize
- Testcases:
- create_form_with_form_instance, xowiki
# Empty hook for OpenACS package level initialization. This is # used e.g. by xowf for adding the work flow mixin classes.insert (scripted)
set __table_name [[self class] table_name] set __id [[self class] id_column] set :$__id ${:object_id} :log "ID insert in $__table_name, id = $__id = [set :$__id]" next foreach {__slot_name __slot} [[self class] array get db_slot] { if {[info exists :$__slot_name]} { set $__slot_name [set :$__slot_name] lappend __vars $__slot_name lappend __atts [$__slot column_name] } } ::xo::dc dml insert_$__table_name "insert into $__table_name ([join $__atts ,]) values (:[join $__vars ,:])"instance_name (setter)
instantiate_forms (scripted)
set form_item_ids [acs::per_request_cache eval -key xotcl-core.instantiate_forms-$forms-$default_lang-$parent_id -no_cache {} -from_cache_indicator from_cache { set form_item_ids {} foreach item_ref [split $forms |] { # # The following regexp should include the majority of valid # items refs. # if {![regexp {^[[:alnum:]:./_-]+$} $item_ref]} { error "invalid form specification '$item_ref'" } #:log "trying to get $item_ref // parent_id $parent_id" set page [:get_page_from_item_ref -use_prototype_pages true -use_package_path true -parent_id $parent_id -default_lang $default_lang $item_ref] #:log "weblog form $item_ref => $page" if {$page ne ""} { lappend form_item_ids [$page item_id] } } set form_item_ids }] # # In case we got the item_ids from the per-request cache, make # sure to load these. This should not be an issue in most # situations, but in the test-suite multiple request functions are # bundled in a "request" such that will become an issue, when the # per-request cache is not flushed quick enough. # if {$from_cache} { #ns_log notice "... instantiate_forms -forms $forms -default_lang $default_lang -parent_id $parent_id --> '$form_item_ids'" ::xo::db::CrClass ensure_item_ids_instantiated -item_ids $form_item_ids } return $form_item_idspackage_id (setter)
package_key (setter)
package_url (setter)
process_init_parameter (scripted)
# Empty hook for package instance initialization, when e.g. one # instance of an xowiki package should behave differently from # another one.query_parameter (forward)
reply_to_user (scripted)
<instance of xo::Package> reply_to_user:handle_http_caching #:log "REPLY [::xo::cc exists __continuation]" if {[::xo::cc exists __continuation]} { #:log "REPLY [::xo::cc set __continuation]" eval [::xo::cc set __continuation] } else { if {[string length $text] > 1} { set default_status_code 200 } else { set default_status_code 204 } set status_code [expr {[::xo::cc exists status_code] ? [::xo::cc set status_code] : $default_status_code}] #:log "REPLY ${:delivery} $status_code ${:mime_type} - length: [string length $text] - [ad_conn peeraddr]" ${:delivery} $status_code ${:mime_type} $text }require_root_folder (scripted, public)
<instance of xo::Package> require_root_folder \ [ -parent_id parent_id ] [ -content_types content_types ] \ -name nameMake sure, the root folder for the given package exists. If not, create it and register all allowed content types. Note that xowiki (and derived packages) define their own version of "require_root_folder" based on form pages. Therefore, this function is just for packages not based on xowiki.
- Switches:
- -parent_id (optional, defaults to
"-100"
)- -content_types (optional)
- -name (required)
- Returns:
- folder_id
- Testcases:
- xowiki_test_cases
set folder_id [::xo::xotcl_package_cache eval root_folder-${:id} { set folder_id [::xo::db::CrClass lookup -name $name -parent_id $parent_id] if {$folder_id == 0} { :log "folder with name '$name' and parent $parent_id does NOT EXIST" set folder_id [::acs::dc call content_folder new -name $name -label ${:instance_name} -parent_id $parent_id -package_id ${:id} -context_id ${:id}] :log "CREATED folder '$name' and parent $parent_id ==> $folder_id" } # Register all specified content types ::xo::db::CrFolder register_content_types -folder_id $folder_id -content_types $content_types #:log "returning from cache folder_id $folder_id" return $folder_id }] #:log "returning from require folder_id $folder_id" return $folder_idreturn_page (scripted)
#:log "--vars=[self args]" set __vars [list] foreach _var $variables { if {[llength $_var] == 2} { # # The variable specification "$_var" is a pair of name and # value. # #if {[util::potentially_unsafe_eval_p -- [lindex $_var 1]]} { # ad_log warning "deprecated usage of variable/value pair $_var, potentially unsafe for 'subst'" #} lappend __vars [lindex $_var 0] [uplevel [list subst [lindex $_var 1]]] } else { # # We have just a variable name, provide a linked variable to # access the value. # set localvar local.$_var upvar $_var $localvar if {[array exists $localvar]} { lappend __vars &$_var $localvar } elseif {[info exists $localvar]} { # ignore undefined variables lappend __vars $_var [set $localvar] } } } if {[info exists form]} { set level [template::adp_level] foreach f [uplevel #$level info vars ${form}:*] { lappend __vars &$f $f upvar #$level $f $f } } # # Substitute the template with the themed template # set adp [template::themed_template $adp] set text [template::adp_include $adp $__vars] if { [lang::util::translator_mode_p] } { set text [::xo::localize $text 1] } #:log "--after adp $text" return [::xo::remove_escapes $text]returnredirect (forward)
set_url (scripted)
:url $url set :object [string range [:url] [string length [:package_url]] end] #:msg "--R object set to ${:object}, url=$url, [:serialize]"update (scripted)
::xo::dc transaction { next :instvar object_id package_key default_locale instance_name ::xo::dc dml update_apm_packages {update apm_packages set package_key = :package_key,default_locale = :default_locale,instance_name = :instance_name where package_id = :object_id } }url (setter)
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables