-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.tcl
More file actions
executable file
·114 lines (81 loc) · 4.27 KB
/
init.tcl
File metadata and controls
executable file
·114 lines (81 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# -- init.tcl
#
# this stuff must go in rivetweb's configuration, I don't see any other
# clear way to make it site specific
#
# this is more correct as it allows to override system packages
# with locally installed equivalent packages
::rivet::apache_log_error info "rweb_root: $rweb_root, website_root: $website_root"
set auto_path [concat $website_root $rweb_root $auto_path]
cd $website_root
package require Itcl
package require rwlogger
package require rwconf
package require rwmenu
package require rwpage
package require rwlink
package require urlcomposer
package require RWTemplate
package require UrlHandler
package require rivetweb
package require RWDummy
package require XMLBase
::rivetweb::setup $rweb_root $website_root
# rivetweb initialization
set website_definitions [file join $::rivetweb::site_base site_defs.tcl]
if {[file exists $website_definitions]} { source $website_definitions }
::rivet::apache_log_error info "default_template: $::rivetweb::default_template"
#set ::rivetweb::url_composer [::rivetweb::UrlComposer #auto $::rivetweb::rewrite_par]
set ::rivetweb::url_composer [::rivetweb::make_url_composer]
# site_defs.tcl is supposed to define the default template, we thus assign this key to the
# last_selected_template variable in order to force a template_chanded signal
set ::rivetweb::last_selected_template rwbase
# rivetweb_init.tcl loads the templates database and hooks database
source [file join $::rivetweb::scripts rivetweb_init.tcl]
# we have both the default template and the template database, we proceeded
# determining the default menuclass
#set ::rivetweb::menuclass [dict get $::rivetweb::templates_db $rivetweb::default_template menuclass]
set ::rivetweb::menuclass [::rivetweb::RWTemplate::template $rivetweb::default_template menuclass]
set website_init [file join $website_root $::rivetweb::website_init]
if {[file exists $::rivetweb::website_init]} {
::rivet::apache_log_error info "running website specific initialization $website_init ([pwd])"
if {[catch {source $website_init} e]} {
::rivet::apache_log_error crit "Error running website specific initialization ($e)"
foreach l [split $errorInfo "\n"] {
::rivet::apache_log_error crit $l
}
}
}
# if we want to have the Scripted datasource we have to load it from within the
# initialization of a specific application ::rivetweb::init Scripted
::rivetweb::init XMLBase last
# this one is guaranteed to be the last datasource
::rivetweb::init RWDummy last
# Application replaceable procedure for the handler list tampering
# The handler list tampering is deprecated in favour of overriding the method
# UrlHandler::next_handler
::rivet::apache_log_error debug "[pwd] - Registered handlers pre tampering [::rwdatas::UrlHandler::registered_handlers]"
::rivet::apache_log_error debug "[pwd] - Handlers arguments pre tampering [::rwdatas::UrlHandler::handlers_arguments]"
::rwdatas::UrlHandler::set_installed_handlers \
[::rivetweb::handlers_list_tampering [::rwdatas::UrlHandler::registered_handlers]]
::rivet::apache_log_error debug "[pwd] - Registered handlers [::rwdatas::UrlHandler::registered_handlers]"
::rivet::apache_log_error debug "[pwd] - Handlers arguments post tampering [::rwdatas::UrlHandler::handlers_arguments]"
# this is the very last operation to do after the initialization. We have just
# instantiated each datasource and we proceed calling the 'init' method for each
# instance in reverse order in the list of handlers. Application level models
# different from the default list based model should provide a meanining about
# the idea of 'reverse order'
# the main reason for deferring this stage is that 'init' method register error
# messages within the RWDummy messages database, but RWDummy has to be instantiated for
# the method 'register_error' to exist
::rivet::apache_log_error debug "Url handlers init [::rwdatas::UrlHandler::handlers_arguments]"
set handlers_arguments [::rwdatas::UrlHandler::handlers_arguments]
foreach ds [lreverse [::rwdatas::UrlHandler::registered_handlers]] {
if {[dict exists $handlers_arguments $ds]} {
::rivet::apache_log_error debug "Running init for handler $ds ([dict get $handlers_arguments $ds])"
$ds init {*}[dict get $handlers_arguments $ds]
} else {
$ds init
}
}
# -- init.tcl