Brad Friedman wrote:
>
> Hi, Jeff
>
> Here's the test.R file.
>
> I'm also copying the RApache-related part of my httpd.conf file in
> case it might be relevant (further below).
>
> Thanks for your help!
Two things:
1. Using return() from sys.source() doesn't work, so you will want to
wrap your code in an if-else statement like so:
--------------------------------------
if(is.null(GET$x) ||
is.na(x)) {
## If x was not supplied or doesn't convert well send error back
to user
## (this bit doesn't work right!)
setContentType("text/html")
cat("x was not supplied or didn't convert")
} else {
## x was succesfully converted. Make a plot with it.
setContentType("image/png")
tfn <- tempfile()
png(tfn, type="cairo", width=800, height=600)
plot(1:as.integer(GET$x))
dev.off()
sendBin(readBin(tfn, "raw", n=
file.info(tfn)$size))
unlink(tfn)
}
DONE
---------------------------------
I should have known better than to suggest return() to you before. It's
just that I was confused about the context in which you were creating
your application.
2. It's more intuitive to use the <Directory> directive rather than the
<Location> directive when using the 'r-script' handler like so:
<Directory /home/hornerj/rapache-1.1.8/test/source>
SetHandler r-script
RHandler sys.source
</Directory>
This means that every file under that directory will be treated as an R
script handled through sys.source(). With your <Location> directive, it
means every url that starts with /R/ will be treated as such and you may
or may not want that to happen. Just something to be aware of...
The whole business with the handlers 'r-script' and 'r-handler' with
RHandler and RFile is quite confusing but leads to a variety of ways to
structure your application. I'm hoping over time users will come up with
better ways to define this in the apache config.
Jeff