second argument with SetHandler r-script?

54 views
Skip to first unread message

Murat Tasan

unread,
Jun 30, 2015, 4:59:40 PM6/30/15
to rap...@googlegroups.com
Hi all --- After reading the docs, I realize I'm still awfully confused about one point:
"r-script is used when you want to call an R function with 2 arguments: the first is the full path to the file, and the second is an R environment."

I see the brew example, where in a <Directory> directive the filename under the directory is passed as the first arg to brew::brew.
But the second arg to brew::brew is not an environment, rather it's another file descriptor (stdout() is the default).

How is this second "R environment" argument passed or specified?
I cannot seem to find an example illustrating its use.

FWIW --- I fully understand the RFileEval case of evaluating the file contents in an anonymous environment, then executing the specified function in that environment.
I just don't understand the details of environment management when using r-script as the handler.
Is it simply that the function specified (e.g. brew::brew) is evaluated in an environment specific to the full URL under that <Directory>?

Any help understanding environments w.r.t r-script is would be greatly appreciated :-)

Cheers,

-Murat

Murat Tasan

unread,
Jul 1, 2015, 12:11:25 AM7/1/15
to rap...@googlegroups.com
Well, I answered my own question, but thought it'd be useful to share here as reference for any future searches.
Apparently r-script with RHandler passes the file and environment as _named_ args, rather than positionals (with the names "file" and "envir", matching two named args in brew::brew). in brew::brew.

Example Apache conf section:

REvalOnStartup "showArgs <- function(...) str(list(...))"
<Directory /some/dirpath/here/*>
    SetHandler r-script
    RHandler showArgs
</Directory>

Navigating to /some/dirpath/here/foo.bar produces:

List of 2
 $ file : chr "/some/dirpath/here/foo.bar"
 $ envir:<environment: 0x7f10d8e17e40> 


Are the docs provided at rapache.net/manual.html sourced on github anywhere so I can make a few clarifying alterations followed by a pull request?
(There are a handful of typos also that I can correct.)

Cheers,

-Murat
Reply all
Reply to author
Forward
0 new messages