Forum OpenACS Development: tDOM and Dom Objects on Server Load problem

I'm having trouble referring to tDOM objects in a tcl page that are created on server load in a -procs.tcl file. Does anyone have experience with this?

In summary, I want to:

  • Pre-parse an XSL document using tDOM in a -procs.tcl file
  • Use that pre-parsed document multiple times in a .tcl file
Here's what I'm doing:

I'm testing the speed benefits of using XSL transforms on some heavily loaded pages over using the templating system (short story, yes, it will be much faster, but not clear how useful it is a general templating solution).

I realized after some load testing that it would be preferable to load the XSL on server load (in packages/acs-templating/tcl/xsl-procs.tcl), and create the XSLTcmd proc then. This would cut out a lot of processing, esp. since the XSL is fairly long.

This is where I get stuck: I can't seem to access the ref'ed proc after the server loads the file. Here's my code:

set template_index_xsl "<blah XML>"

dom parse $template_index_xsl temp_xsl_doc

$temp_xsl_doc toXSLTcmd template_index_xsl_compiled

nsv_set xsl_templates index $template_index_xsl_compiled
This puts a variable something like XSLTcmd0x292929 in the nsv array. The problem is the proc named XSLTcmd0x293939 doesn't seem to be available from any of my tcl scripts. I've double checked namespaces, and I'm certain that I'm referring to the command correctly.

Can anyone explain just what's happening here, or provide any direction?

Thank you!

Posted by Dossy Shiobara on
Even though you made the proc name available to other threads and Tcl interps via the NSV, the proc still only exists in the Tcl interp where it was created.  You won't be able to call it from another interp.

Yet another reason why I'm not really happy with tDOM ...

-- Dossy

Posted by Andrew Piskorski on
Peter, I've no idea how tDOM goes about creating its procs, but if it doesn't give you a way to easily repoduce that process in another interp, the Tcl Thread Extension and/or ttrace might be able to help you do so.
Posted by Andrew Piskorski on
Hm, or use plain old ns_eval?
Posted by Peter Vessenes on
Andrew, Mmmm. ns_eval... I'll try it out.
Posted by Peter Vessenes on
Okay, script 1:
ns_share temp_xsl_doc catalogxml

ns_eval dom parse -simple  {$template_index_xsl} temp_xsl_doc
ns_eval dom parse -simple {$myxml} catalogxml
Script 2:
ns_share temp_xsl_doc catalogxml
$catalogxml xslt $temp_xsl_doc return_html
ns_return 200 text/html [$return_html asHTML ]
invalid command name "domDoc0xbd51b38"
    while executing
"$catalogxml xslt $temp_xsl_doc return_html"
    ("uplevel" body line 157)
    invoked from within
"uplevel {...
It looks to me like ns_eval is a nice idea, but tdom is doing something funky which makes this a no go. I'll try it with -sync first, but if not, then I'll have to check out the thread extensions. Can anybody see any errors here?
Posted by Peter Vessenes on
Update: No -sync option in my version of AOLServer (3.3ad+13+others)