Forum OpenACS Development: Re: Why XML for .xql query dispatcher files?

Collapse
Posted by John Sequeira on
Andy,
For portable.nsd, I convert all the XQL files to a TCL file to speed up the code/restart Apache/test cycle. You can download the code from the pnsd site if you're interested - it's pretty simple.

#Use this command to cache the xql into a .dat file for quick loading.
#This will indescriminantly load each and every query for all supported databases - it can be made more efficient

proc load_xql {} {

    if [ ns_config -bool pnsd/parameters LoadXqlFromCache ] {
	ns_log error "Your config file has disabled xql-file parsing.  Please change option pnsd/parametere LoadXqlFromCache"
	exit
    }

    if [empty_string_p [info commands ::db_qd_load_query_file]] {
	ns_log error "db_qd_load_query_file is not defined.  Did you forget to pnsd::source_openacs?"
	exit
    }

    set arrName OACS_FULLQUERIES
    set filename [file join $::pnsd::home xql.dat]
    uplevel 1 [list trace var $arrName wu [list ::pnsd::persist'save $filename]]
    
    set xqlfiles  [ ::fileutil::findByPattern $::pnsd::root -glob  *.xql    ] 

    foreach  file  $xqlfiles {
#	puts $file; 
	if {! [regexp postgresql $file]} {
	    db_qd_load_query_file $file
	}
    }
    


}


}
#namespace


See this tcl wiki page for a look at array serialization procs I'm using.