Hi Massimo,
I tried your approach with success. I added
RivetServerConf BeforeScript "load_env reqenv; cd [file dirname
$reqenv(SCRIPT_FILENAME)]"
to our Rivet directives.
But I'm not quite sure if this the right place for the command. Because
for me it is the correction of a misbehaviour. But as long as it is not
clear who is guilty and if there is not introduced an unwanted
side-effect, this way sounds as a good solution.
Thanks and best regards
Sven
Am 18.01.2012 12:08, schrieb Massimo Manghi:
Hi Sven
I think a more practical approach could be to tell Rivet to
work starting from a specific directory at every request. It's
easy because Rivet has the BeforeScript directive for this sort
of things
RivetServerConf BeforeScript "cd<my-app-root-dir>"
you may change this command and cd into the filename dir by
elaborating it a bit. The filename variable is stored in one
of the environment variables (see 'load_env' command)
RivetServerConf BeforeScript "load_env reqenv"
RivetServerConf BeforeScript "cd [file dirname $reqenv(FILENAME)]"
Developing with Rivet I progressively moved everything
has to be done at each request into the BeforeScript. The more
I think of it the stronger I feel it's the consistent way to
work. Template scripts just 'fill the holes' in the template using
data prepared before the actual template is run.
Keep in mind that Rivet configuration directives concatenate
in a single script subsequent calls to the same directive
RivetServerConf BeforeScript "cd<my webspace>"
RivetServerConf BeforeScript "source myAppRequestProcessing.tcl"
it could be your solution if your scripts assume to work starting
from the a specific<my webspace> directory. This feature is helpful
also because you may have script generic enough to be deployed
in different places and let the configuration set up the
environment for them
-- Massimo
On mer, 2012-01-18 at 09:47 +0100, Sven wrote:
Hello Massimo,
I think I found a solution. Thank you for your hint about the implicit
chdir.
In mod_rivet.c (after the chdir fore Apache ) I added some code to chdir
also for the TCL interpreter:
//XXX: Dirty fix
Tcl_Obj *chdir = Tcl_NewStringObj("cd [file dirname ", -1);
Tcl_IncrRefCount(chdir);
Tcl_AppendToObj(chdir, r->filename, -1);
Tcl_AppendToObj(chdir, "]", -1);
Tcl_EvalObjEx(interp, chdir, TCL_EVAL_DIRECT);
Tcl_DecrRefCount(chdir);
I dont know if this robust and the most efficient way. But it works for me.
In the end I don't know exactly why it is that way. The interpreter
somewhere holds a structure with the cwd, which may be out of sync with
different subsequent requests. But it was still working correctly in the
most cases. But why it doesn't work only if some very special code is
executed ...
Best regards
Sven
<snipped>
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscr...@tcl.apache.org
For additional commands, e-mail: rivet-dev-h...@tcl.apache.org