%3 ::xo::Package ::xo::Package exists_form_parameter exists_query_parameter form_parameter get_parameter handle_http_caching init initialize insert instantiate_forms process_init_parameter query_parameter reply_to_user require_root_folder return_page returnredirect set_url update ::xo::db::Object ::xo::db::Object delete initialize_loaded_object insert save save_new update ::xo::Package->::xo::db::Object ::xo::db::chat_transcript ::xo::db::chat_transcript insert save_new update ::xo::db::chat_transcript->::xo::db::Object ::xo::db::chat_room ::xo::db::chat_room ban_user count_messages create_transcript delete delete_messages flush grant_creator grant_moderator grant_user insert post_message revoke_moderator revoke_user save_new transcript_messages unban_user update ::xo::db::chat_room->::xo::db::Object ::xo::db::CrItem ::xo::db::CrItem changed_redirect_url current_user_id delete fix_content initialize_loaded_object is_cached_object is_package_root_folder privilege=creator rename save save_new set_live_revision update update_attribute_from_slot update_content update_item_index update_revision www-revisions ::xo::db::CrItem->::xo::db::Object ::xo::db::CrCache::Item ::xo::db::CrCache::Item ::xo::db::CrItem->::xo::db::CrCache::Item instmixin ::xo::db::apm_parameter ::xo::db::apm_parameter insert update ::xo::db::apm_parameter->::xo::db::Object ::xo::parameter ::xo::parameter ::xo::db::apm_parameter->::xo::parameter instmixin ::xotcl::Object ::xotcl::Object ::xo::db::Object->::xotcl::Object ::xo::oauth::Package ::xo::oauth::Package → fill → reset index init insert ::xo::oauth::Package->::xo::Package ::xowiki::Package ::xowiki::Package → get_package_id_from_page_id → get_url_from_id → google_sitemapindex → instantiate_page_from_id → is_xowiki_p → preferredCSSToolkit → reparent_site_wide_pages call check_permissions clipboard-copy condition=has_class condition=has_name create_new_snippet default_language default_locale delete_revision error_msg external_name flush_name_cache flush_page_fragment_cache flush_references folder_path get_adp_template get_ids_for_bulk_actions get_lang_and_name get_package_id_from_page_name get_page_from_item_or_revision_id get_page_from_item_ref get_page_from_name get_page_from_super get_parameter get_parameter_from_parameter_page get_parent_and_name import init insert invoke item_info_from_id item_info_from_url item_ref join_name lookup make_form_link make_link normalize_name normalize_path package_path prefixed_lookup pretty_link query_parameter_return_url reparent require_folder_object require_root_folder resolve_package_path resolve_page resolve_page_name resolve_page_name_and_init_context show_page_order simple_item_ref split_name validate_tag www-change-page-order www-delete www-edit-category-tree www-edit-new www-google-sitemap www-google-sitemapindex www-import-prototype-page www-manage-categories www-refresh-login www-reindex www-rss www-update-references ::xowiki::Package->::xo::Package ::xowiki::ParameterCache ::xowiki::ParameterCache ::xowiki::Package->::xowiki::ParameterCache instmixin ::xolirc::Package ::xolirc::Package → create-page-from-log → process-all-logs dash-date get-html-from-log initialize insert query-actual-log ::xolirc::Package->::xowiki::Package ::s5::Package ::s5::Package init insert ::s5::Package->::xowiki::Package ::xowf::Package ::xowf::Package → create_new_workflow_page call destroy initialize insert ::xowf::Package->::xowiki::Package

Class ::xo::Package

::xo::Package[i] 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[i]
  • superclass: ::xo::db::Object[i]
  • subclass: ::xo::oauth::Package[i], ::xowiki::Package[i]
::xo::PackageMgr create ::xo::Package \
     -superclass ::xo::db::Object

Methods (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]
    
    :initialize
  • initialize (scripted)

     <instance of xo::Package[i]> 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_ids
  • package_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[i]> reply_to_user

    Testcases:
    create_folder_with_page, xowf, create_workflow_with_instance, create_form_with_form_instance
    
    :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[i]> require_root_folder \
        [ -parent_id parent_id ] [ -content_types content_types ] \
        -name name 

    Make 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_id
  • return_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)