From 987f2b2a5542634c8f13b562857d2cd99efd3ccc Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Fri, 18 Oct 2013 22:19:25 -0500 Subject: [PATCH 1/3] closes #236: use sys.source(envir=) instead of source(local=) --- R/shiny.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/shiny.R b/R/shiny.R index bb9b09ab7..c4e9f186e 100644 --- a/R/shiny.R +++ b/R/shiny.R @@ -764,7 +764,7 @@ dynamicHandler <- function(filePath, dependencyFiles=filePath) { if (file.exists(filePath)) { local({ cacheContext$with(function() { - source(filePath, local=new.env(parent=.GlobalEnv)) + sys.source(filePath, envir=new.env(parent=.GlobalEnv)) }) }) } @@ -1018,11 +1018,11 @@ startAppDir <- function(port=8101L, workerId) { stop(paste("server.R file was not found in", getwd())) if (file.exists(globalR)) - source(globalR, local=FALSE) + sys.source(globalR, envir=.GlobalEnv) shinyServer(NULL) serverFileTimestamp <- file.info(serverR)$mtime - local(source(serverR, local=new.env(parent=.GlobalEnv))) + local(sys.source(serverR, envir=new.env(parent=.GlobalEnv))) if (is.null(.globals$server)) stop("No server was defined in server.R") @@ -1032,7 +1032,7 @@ startAppDir <- function(port=8101L, workerId) { if (!identical(mtime, serverFileTimestamp)) { shinyServer(NULL) serverFileTimestamp <<- mtime - local(source(serverR, local=new.env(parent=.GlobalEnv))) + local(sys.source(serverR, envir=new.env(parent=.GlobalEnv))) if (is.null(.globals$server)) stop("No server was defined in server.R") } From a9e4ce005daa1df76e1227aa7974071fec82879d Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Fri, 18 Oct 2013 22:38:32 -0500 Subject: [PATCH 2/3] closes #238: use keep.source() for sys.source() --- R/shiny.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/shiny.R b/R/shiny.R index c4e9f186e..abc89ab35 100644 --- a/R/shiny.R +++ b/R/shiny.R @@ -764,7 +764,7 @@ dynamicHandler <- function(filePath, dependencyFiles=filePath) { if (file.exists(filePath)) { local({ cacheContext$with(function() { - sys.source(filePath, envir=new.env(parent=.GlobalEnv)) + sys.source(filePath, envir=new.env(parent=.GlobalEnv), keep.source=TRUE) }) }) } @@ -1018,11 +1018,11 @@ startAppDir <- function(port=8101L, workerId) { stop(paste("server.R file was not found in", getwd())) if (file.exists(globalR)) - sys.source(globalR, envir=.GlobalEnv) + sys.source(globalR, envir=.GlobalEnv, keep.source=TRUE) shinyServer(NULL) serverFileTimestamp <- file.info(serverR)$mtime - local(sys.source(serverR, envir=new.env(parent=.GlobalEnv))) + local(sys.source(serverR, envir=new.env(parent=.GlobalEnv), keep.source=TRUE)) if (is.null(.globals$server)) stop("No server was defined in server.R") @@ -1032,7 +1032,7 @@ startAppDir <- function(port=8101L, workerId) { if (!identical(mtime, serverFileTimestamp)) { shinyServer(NULL) serverFileTimestamp <<- mtime - local(sys.source(serverR, envir=new.env(parent=.GlobalEnv))) + local(sys.source(serverR, envir=new.env(parent=.GlobalEnv), keep.source=TRUE)) if (is.null(.globals$server)) stop("No server was defined in server.R") } From c538e9c6d46d51dde4b897025f3f7683e736ba8b Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Wed, 20 Nov 2013 18:00:24 -0600 Subject: [PATCH 3/3] use globalenv() instead of .Globalenv; remove local() --- R/shiny.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/shiny.R b/R/shiny.R index abc89ab35..590d5e643 100644 --- a/R/shiny.R +++ b/R/shiny.R @@ -764,7 +764,7 @@ dynamicHandler <- function(filePath, dependencyFiles=filePath) { if (file.exists(filePath)) { local({ cacheContext$with(function() { - sys.source(filePath, envir=new.env(parent=.GlobalEnv), keep.source=TRUE) + sys.source(filePath, envir=new.env(parent=globalenv()), keep.source=TRUE) }) }) } @@ -1018,11 +1018,11 @@ startAppDir <- function(port=8101L, workerId) { stop(paste("server.R file was not found in", getwd())) if (file.exists(globalR)) - sys.source(globalR, envir=.GlobalEnv, keep.source=TRUE) + sys.source(globalR, envir=globalenv(), keep.source=TRUE) shinyServer(NULL) serverFileTimestamp <- file.info(serverR)$mtime - local(sys.source(serverR, envir=new.env(parent=.GlobalEnv), keep.source=TRUE)) + sys.source(serverR, envir=new.env(parent=globalenv()), keep.source=TRUE) if (is.null(.globals$server)) stop("No server was defined in server.R") @@ -1032,7 +1032,7 @@ startAppDir <- function(port=8101L, workerId) { if (!identical(mtime, serverFileTimestamp)) { shinyServer(NULL) serverFileTimestamp <<- mtime - local(sys.source(serverR, envir=new.env(parent=.GlobalEnv), keep.source=TRUE)) + sys.source(serverR, envir=new.env(parent=globalenv()), keep.source=TRUE) if (is.null(.globals$server)) stop("No server was defined in server.R") }