::xotcl::Class
::xo::PackageMgr
Class Hierarchy of ::xo::PackageMgr
- ::xotcl::Object
- Meta-class:
- ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- Methods for instances:
- __api_make_doc, __api_make_forward_doc, __timediff, abstract, ad_doc, ad_forward, ad_proc, appendC, arrayC, asHTML, autonameC, check, classC, cleanupC, configureC, containsC, copyC, db_0or1rowC, db_1rowC, debug, defaultmethodC, destroyC, destroy_on_cleanup, dot_append_method, dotclass, dotcode, dotquote, dotquotel, ds, evalC, existsC, extractConfigureArg, filterC, filterguardC, filtersearch, forward, hasclass, incrC, infoC, init, instvarC, invarC, isclass, ismetaclass, ismixin, isobject, istype, lappendC, log, method, mixinC, mixinguardC, moveC, msg, noinitC, objectparameter, parametercmdC, proc, procsearch, qn, requireNamespaceC, residualargsC, self, serialize, setC, set_instance_vars_defaults, show-object, substC, traceC, unknown, unsetC, uplevelC, upvarC, volatileC, vwait
- Methods to be applied on the class (in addition to the methods provided by the meta-class):
- getExitHandler, setExitHandler, unsetExitHandler
- ::xotcl::Class
- Meta-class:
- ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- Parameter for instances:
- __default_metaclass (default "::xotcl::Class"), __default_superclass (default "::xotcl::Object")
- Methods for instances:
- ad_instproc, allinstances, allocC, createC, deallocC, extend_slot, infoC, instfilterC, instfilterguardC, instforward, instinvarC, instmixinC, instmixinguardC, instparametercmdC, instproc, method, newC, parameter, recreateC, slots, superclassC, unknown, uses
- Methods to be applied on the class (in addition to the methods provided by the meta-class):
- __unknown
- ::xo::db::Class
- Meta-class:
- ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- Parameter for instances:
- abstract_p (default "f"), auto_save (default "false"), id_column, name_method (default ""), object_type (default "[self]"), pretty_name, pretty_plural, security_inherit_p (default "t"), sql_package_name, supertype (default "acs_object"), table_name, with_table (default "true")
- Methods for instances:
- check_default_values, check_table_atts, create_object_type, db_slots, dbproc_nonposargs, drop_object_type, fetch_query, fix_function_args, generate_proc_body, generate_psql, get_context, get_function_args, get_instances_from_db, init, init_type_hierarchy, initialize_acs_object, instance_select_query, instantiate_objects, mk_insert_method, mk_save_method, new_acs_object, new_persistent_object, object_types, object_types_query, sql-arguments, table_definition, unknown
- Methods to be applied on the class (in addition to the methods provided by the meta-class):
- class_to_object_type, create_all_functions, delete, delete_all_acs_objects, drop_type, exists_in_db, get_all_package_functions, get_class_from_db, get_instance_from_db, get_object_type, get_table_name, object_type_exists_in_db, object_type_to_class
Class Relations
- superclass: ::xo::db::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
::xotcl::Class create ::xo::PackageMgr \
-superclass ::xo::db::Class \
-parameter package_key
Methods
::xo::PackageMgr
get_package_class_from_package_key package_key
Obtain the package class from a package key
- Parameters:
-
package_key
::438597 proc get_package_class_from_package_key package_key {
foreach p [::xo::PackageMgr allinstances] {
# Sanity check for old apps, having not set the package key.
# TODO: remove this in future versions, when package_keys are enforced
if {![$p exists package_key]} {
ns_log notice "!!! You should provide a package_key for $p [$p info class] !!!"
continue
}
if {[$p package_key] eq $package_key} {
return $p
}
}
return ""
}
<instance of ::xo::PackageMgr
> first_instance \
[ -privilege privilege ] [ -party_id party_id ]
- Switches:
- -privilege (optional)
- -party_id (optional)
- Returns:
- return first mounted instance of this type
::438597 instproc first_instance {-privilege -party_id} {
my instvar package_key
if {[info exists privilege]} {
set sql [::xo::db::sql select -vars package_id -from "apm_packages, acs_object_party_privilege_map ppm, site_nodes s" -where {
package_key = :package_key
and s.object_id = package_id
and ppm.object_id = package_id
and ppm.party_id = :party_id
and ppm.privilege = :privilege
} -limit 1]
db_string [my qn get_package_id] $sql
} else {
::xo::parameter get_package_id_from_package_key -package_key $package_key
}
}
<instance of ::xo::PackageMgr
> initialize [ -ad_doc ad_doc ] \
[ -parameter parameter ] [ -package_id package_id ] [ -url url ] \
[ -user_id user_id ] [ -actual_query actual_query ] \
[ -original_url_and_query original_url_and_query ] \
[ -init_url init_url ] [ -keep_cc keep_cc ] \
[ -form_parameter form_parameter ] [ -export_vars export_vars ]
Create the connection context ::xo::cc and a package object
if these are none defined yet. The connection context ::xo::cc
and the package object will be destroyed on cleanup,
when the global variables are reclaimed.
As a side effect this method sets in the calling context
the query parameters and package_id as variables, using the
"defaults" for default values.
init_url false requires the package_id to be specified and
a call to Package instproc set_url to complete initialization.
keep_cc true means that the original connection context
is preserved (i.e. not altered) in case it exists already.
- Switches:
- -ad_doc (optional)
- -parameter (optional)
- -package_id (defaults to
"0"
) (optional) - -url (optional)
- -user_id (defaults to
"-1"
) (optional) - -actual_query (defaults to
" "
) (optional) - -original_url_and_query (optional)
- -init_url (defaults to
"true"
) (optional) - -keep_cc (defaults to
"false"
) (optional) - -form_parameter (optional)
- -export_vars (defaults to
"true"
) (optional)
::438597 instproc initialize {-ad_doc {-parameter ""} {-package_id 0} {-url ""} {-user_id -1} {-actual_query " "} -original_url_and_query {-init_url true} {-keep_cc false} -form_parameter {-export_vars true}} {
#my msg "--i [self args], URL=$url, init_url=$init_url"
if {$url eq "" && $init_url} {
set url [root_of_host [ad_host]][ns_conn url]
#my log "--CONN ns_conn url -> $url"
}
# get package_id from url in case it is not known
set package_id [ConnectionContext require_package_id_from_url -package_id $package_id $url]
# require connection context if needed
ConnectionContext require -keep_cc $keep_cc -package_id $package_id -user_id $user_id -parameter $parameter -url $url -actual_query $actual_query
if {[info exists original_url_and_query]} {
::xo::cc original_url_and_query $original_url_and_query
}
if {[info exists form_parameter]} {
::xo::cc array set form_parameter $form_parameter
}
# create package object if necessary
if {$keep_cc} {
my require $package_id
} else {
my require -url $url $package_id
}
#
# In case the login expired, we can force an early login to
# prevent later login redirects, which can cause problems
# from within catch operations. The package can decide, if
# it want to force a refresh of the login, even if some pages
# might not require the real user_id.
#
#my msg "force [$package_id force_refresh_login] && # [::xo::cc set untrusted_user_id] != [::xo::cc user_id]"
if {[$package_id force_refresh_login] &&
[::xo::cc set untrusted_user_id] != [::xo::cc user_id]} {
auth::require_login
}
if {$export_vars} {::xo::cc export_vars -level 2}
return $package_id
}
<instance of ::xo::PackageMgr
> instances \
[ -include_unmounted include_unmounted ] [ -closure closure ]
- Switches:
- -include_unmounted (defaults to
"false"
) (optional) - include unmounted package instances
- -closure (defaults to
"false"
) (optional) - include instances of subclasses of the package
- Returns:
- list of package_ids of xowiki instances
::438597 instproc instances {{-include_unmounted false} {-closure false}} {
my instvar package_key
if {$include_unmounted} {
set result [db_list [my qn get_xowiki_packages] {select package_id from apm_packages where package_key = :package_key}]
} else {
set result [db_list [my qn get_mounted_packages] {select package_id from apm_packages p, site_nodes s where package_key = :package_key and s.object_id = p.package_id}]
}
if {$closure} {
foreach subclass [my info subclass] {
foreach id [$subclass instances -include_unmounted $include_unmounted -closure true] {
lappend result $id
}
}
}
return [lsort -integer $result]
}
<instance of ::xo::PackageMgr
> require [ -url url ] package_id
Create package object if needed.
- Switches:
- -url (optional)
- Parameters:
-
package_id
::438597 instproc require {{-url ""} package_id} {
if {$package_id eq ""} {error "package_id must not be empty"}
#my log "--R $package_id exists? [my isobject ::$package_id] url='$url'"
if {![my isobject ::$package_id]} {
#my log "--R we have to create ::$package_id //url='$url'"
#
# To make initialization code generic, we obtain from the
# package_id the class of the package.
#
set package_key [apm_package_key_from_id $package_id]
set package_class [[self class] get_package_class_from_package_key $package_key]
if {$package_class eq ""} {
#
# For some unknown reason, we did not find the key. We want
# to be conservative, behave like in older versions that did
# not provide a package_key, but required for this call to be
# invoked on the actual class of the package. We provide
# compatibility, but complain in ns_log.
#
# (E.g. hypermail2xowiki uses this)
ns_log notice "Could not find ::xo::Package with key $package_key ($package_id)"
set package_class [self]
}
if {$url ne ""} {
$package_class create ::$package_id -destroy_on_cleanup -id $package_id -url $url
} else {
$package_class create ::$package_id -destroy_on_cleanup -id $package_id
}
} else {
if {$url ne ""} {
::$package_id set_url -url $url
}
}
}
Instances
::s5::Package
, ::xo::Package
, ::xowf::Package
, ::xowiki::Package![[i]](/resources/acs-subsite/ZoomIn16.gif)