nstrace::statescript (private)

 nstrace::statescript [ file ]

Defined in packages/acs-tcl/tcl/tcllib-doc-procs.tcl

Generate the NaviServer interpreter blueprint used to initialize other Tcl interpreters from the current interpreter state.

Parameters:
file (optional)
Optional path to write the generated script to.
Returns:
The generated Tcl script when no file is specified.

Partial Call Graph (max 5 caller/called nodes):
acs::tcllib::register_documentation acs::tcllib::register_documentation (private) nstrace::statescript nstrace::statescript acs::tcllib::register_documentation->nstrace::statescript packages/acs-admin/www/install/install-3.tcl packages/acs-admin/ www/install/install-3.tcl packages/acs-admin/www/install/install-3.tcl->nstrace::statescript _ _ (public) nstrace::statescript->_ nsf::object::exists nsf::object::exists nstrace::statescript->nsf::object::exists nstrace::namespaces nstrace::namespaces (private) nstrace::statescript->nstrace::namespaces

Testcases:
No testcase defined.
Source code:
            variable scripts

            set script {}
            set import {}

            #
            # Invoke [load] script generator first
            # as this must pull up all loaded mods.
            #

            foreach cmd $scripts {
                if {$cmd eq {load}} {
                    append script [script::_$cmd] \n
                }
            }

            #
            # Invoke rest of script generators, but skip
            # [rename] as this will be loaded last.
            #

            foreach cmd $scripts {
                if {$cmd ne {load} && $cmd ne {rename}} {
                    append script [script::_$cmd] \n
                }
            }

            #
            # Serialize all known namespaces. At this
            # point user callbacks have possibly masked
            # some of the existing namespaces.
            #

            # Filter nsf namespaces from the list of all namespaces,
            # except the one from XOTcl or from the next Scripting
            # Framework. The filter clauses are designed to work with
            # XOTcl 1.* and the Next Scripting Framework (i.e. XOTcl
            # 2.0 and NX).
            #
            set nsps [list]
            if {[info commands ::nsf::object::exists] ne ""} {
                # NX, XOTcl 2
                set xotcl 2
                foreach n [namespaces] {
                    if {$n eq "::nsf"
                        || [string match "::nsf::*" $n]
                        || [::nsf::object::exists $n]} { continue }
                    lappend nsps $n
                }
            } elseif {[info commands ::xotcl::Object] ne ""} {
                # XOTcl 1
                set xotcl 1
                foreach n [namespaces] {
                    if {[string match "::xotcl*" $n]
                        || [::xotcl::Object isobject $n]} { continue}
                    lappend nsps $n
                }
            } else {
                set xotcl 0
                set nsps [namespaces]
            }

            #puts stderr "remaining namespaces [join [lsort $nsps] \n]"

            # Serialize the remaining namespaces
            foreach n $nsps {
                foreach {s i} [_serializensp $n] {
                    if {[string length $s]} {
                        append script "namespace eval [list $n] {" \n
                        append script $s  \n
                        append script "}" \n
                    }
                    if {[string length $i]} {
                        append import "namespace eval [list $n] {" \n
                        append import $i  \n
                        append import "}" \n
                    }
                }
            }

            #
            # Invoke [rename] script generators before XOTcl to allow
            # it to overload content...
            #
            foreach cmd $scripts {
                if {$cmd eq {rename}} {
                    append script [script::_$cmd] \n
                }
            }

            if {$xotcl > 0} {
                #
                # Serialize XOTcl/NX content
                #
                if {[catch {::Serializer all} objects]} {
                    ns_log warning "NX/XOTcl extension not loaded; classes an objects will not be included in blueprint (error: $objects; $::errorInfo)."
                    set objects ""
                } else {
                    #
                    # Add the serialized objects after the namespace
                    # imports and ensemble recreators, such that calls
                    # from their constructors can use it.
                    #
                    append import  \n "namespace import -force ::xotcl::*" \n $objects \n

                    if {$xotcl > 1} {
                        #
                        # The serialization of the objects redefines
                        # the Serializer object, therefore, we have to
                        # repeat the namespace import.
                        #
                        append import  "namespace import -force ::nx::serializer::Serializer" \n
                    }
                }
            }

            #
            # Import commands from other namespaces
            #

            if {[string length $import]} {
                append script $import \n
            }

            #
            # Invoke [rename] script generators last
            # ... deactivated by GN

            #foreach cmd $scripts {
            #    if {$cmd eq {rename}} {
            #      append script [script::_$cmd] \n
            #    }
            #}

            #
            # Script is output to file mainly for
            # interactive debugging purposes. The first line
            # gives you always the latest version, the second
            # one is useful for debugging e.g. ns_eval.

            #if {1} {_savescript /tmp/__ns_blueprint.tcl $script}
            #if {1} {_savescript /tmp/__ns_blueprint[clock format [clock seconds] -format %d-%b-%Y-%H:%M:%S].tcl $script}

            # Preserve provided package versions after restoring definitions.
            # Pure Tcl packages have no native load entry to recreate these.
            append script [_serializepackages]

            if {$file ne ""} {
                _savescript $file $script
            } else {
                return $script
            }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: