1# $Id: aol-xotcl.tcl,v 1.15 2007/08/14 16:38:26 neumann Exp $
2
3#
4# Load XOTcl library and some related packages.
5# We expect to find them somewhere in standard
6# Tcl package search path (the auto_path var)
7# The simplest location is to put them under
8# the "lib" directory within the AOLserver tree.
9#
10
11package require XOTcl; namespace import ::xotcl::*
12package require xotcl::serializer
13ns_log notice "XOTcl version $::xotcl::version$::xotcl::patchlevel loaded"
14
15#
16# Overload procedure defined in bin/init.tcl.
17# It is now XOTcl-savvy in how it treats some
18# special namespaces.
19#
20
21proc _ns_savenamespaces {} {
22    set script [_ns_getpackages]
23    set import ""
24    set nslist ""
25    _ns_getnamespaces namespaces
26    foreach n $namespaces {
27        if {[string match "::xotcl*" $n] == 0
28	    && ([catch {::xotcl::Object isobject $n} ret] || $ret == 0)} {
29            lappend nslist $n
30        }
31    }
32    foreach n $nslist {
33        foreach {ns_script ns_import} [_ns_getscript $n] {
34            append script [list namespace eval $n $ns_script] \n
35            if {$ns_import ne ""} {
36                append import [list namespace eval $n $ns_import] \n
37            }
38        }
39    }
40    if {[catch {::Serializer all} objects]} {
41        ns_log notice "XOTcl extension not loaded; will not copy objects\
42        (error: $objects; $::errorInfo)."
43        set objects ""
44    }
45    ns_ictl save [append script \n \
46	"namespace import -force ::xotcl::*" \n \
47	$objects \n $import]
48    # just for debugging purposes
49    if {0} {
50      set f [open [::xotcl::tmpdir]/__aolserver-blueprint.tcl w]
51      puts $f $script
52      close $f
53    }
54}
55
56#
57# Source XOTcl files from shared/private library
58# the way AOLserver does for plain Tcl files.
59#
60
61proc _my_sourcefiles {shared private} {
62    set files ""
63    foreach file [lsort [glob -nocomplain -directory $shared *.xotcl]] {
64        if {[file exists [file join $private [file tail $file]]] == 0} {
65            lappend files $file
66        }
67    }
68    foreach file [lsort [glob -nocomplain -directory $private *.xotcl]] {
69        lappend files $file
70    }
71    foreach file $files {
72        _ns_sourcefile $file
73    }
74}
75
76ns_eval {
77  _my_sourcefiles [ns_library shared] [ns_library private]
78}
79
80# EOF $RCSfile: aol-xotcl.tcl,v $
81
82