template::adp_init (public)

 template::adp_init type file_stub

Defined in packages/acs-templating/tcl/parse-procs.tcl

Ensures that both data source Tcl files and compiled ADP templates are wrapped in procedures in the current interpreter. Procedures are cached in byte code form in the interpreter, so this is more efficient than sourcing a Tcl file or parsing the template every time. Also checks the modification time on the source file to ensure that the procedure is up-to-date.

Parameters:
type - Either ADP (template) or Tcl (code)
file_stub - The root (sans file extension) of the absolute path to the .adp or .tcl file to source.

Partial Call Graph (max 5 caller/called nodes):
%3 test_callgraph__bad_page_calls callgraph__bad_page_calls (test acs-api-browser) template::adp_init template::adp_init test_callgraph__bad_page_calls->template::adp_init apm_package_id_from_key apm_package_id_from_key (public) template::adp_init->apm_package_id_from_key parameter::get parameter::get (public) template::adp_init->parameter::get template::adp_compile template::adp_compile (public) template::adp_init->template::adp_compile template::iconset template::iconset (private) template::adp_init->template::iconset template::util::read_file template::util::read_file (public) template::adp_init->template::util::read_file template::adp_parse template::adp_parse (public) template::adp_parse->template::adp_init template::adp_prepare template::adp_prepare (private) template::adp_prepare->template::adp_init template::form::template template::form::template (private) template::form::template->template::adp_init template::list::render_filters template::list::render_filters (public) template::list::render_filters->template::adp_init template::list::render_form_filters template::list::render_form_filters (private) template::list::render_form_filters->template::adp_init

Testcases:
callgraph__bad_page_calls
Source code:
    #
    # Depending on the iconset, the result of the compiled template
    # might be different. So, cache per iconset
    #
    set cache [iconset]-$type
    #
    # Check, if the compiled proc exists already.
    #
    set proc_name [namespace which ::template::mtimes::${cache}::$file_stub]
    #ns_log notice "$type $file_stub -> '$proc_name'"
    
    set pkg_id [apm_package_id_from_key acs-templating]
    set refresh_cache [parameter::get  -package_id $pkg_id  -parameter RefreshCache  -default "as needed"]

    if {$proc_name eq "" || $refresh_cache ne "never" } {
        set mtime [file mtime $file_stub.$type]
        if {$proc_name eq ""
            || $mtime != [$proc_name]
            || $refresh_cache eq "always"} {
            #
            # Either the procedure does not already exist or is not
            # up-to-date
            #
            namespace eval ::template::code::${cache} {}
            switch -exact $type {

                tcl {
                    set code [template::util::read_file $file_stub.tcl]
                }
                default {
                    set code [adp_compile -file $file_stub.$type]
                }
            }
            #ns_log notice "$type $file_stub -> compiled '$code'"

            #
            # Wrap the code for both types of files within an uplevel
            # in the declared procedure, so that data sources are set
            # in the same frame as the code that outputs the template.
            #
            # Here we add profiling calls if developer support exists
            # on the system.
            #
            if {[namespace which ::ds_enabled_p] ne ""} {
                proc ::template::code::${cache}::$file_stub {} "if {\[::ds_enabled_p\] && \[::ds_collection_enabled_p\] && \[::ds_profiling_enabled_p\]} { ds_profile start $file_stub.$type }
uplevel {
    $code
}
if {\[::ds_enabled_p\] && \[::ds_collection_enabled_p\] &&\[::ds_profiling_enabled_p\]} { ds_profile stop $file_stub.$type }\n"
      } else {
        proc ::template::code::${cache}::$file_stub {} "
uplevel {
    $code
}\n"
      }
      namespace eval ::template::mtimes::${cache} {}
      proc ::template::mtimes::${cache}::$file_stub {} "return $mtime"
    }
  }
  return ::template::code::${cache}::$file_stub
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: