changeset 1993:3d1d44111906

Change Basis.getenv to return None outside the context of a web request
author Adam Chlipala <adam@chlipala.net>
date Tue, 04 Mar 2014 08:46:33 -0500
parents 7075acda4456
children 94529780bbcf
files src/c/urweb.c tests/getenv.ur tests/getenv.urp
diffstat 3 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/c/urweb.c	Tue Feb 25 16:34:04 2014 -0500
+++ b/src/c/urweb.c	Tue Mar 04 08:46:33 2014 -0500
@@ -3669,7 +3669,10 @@
 }
 
 uw_Basis_string uw_Basis_getenv(uw_context ctx, uw_Basis_string name) {
-  return ctx->get_env(ctx->get_env_data, name);
+  if (ctx->get_env)
+    return ctx->get_env(ctx->get_env_data, name);
+  else
+    return NULL;
 }
 
 uw_Basis_string uw_unnull(uw_Basis_string s) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/getenv.ur	Tue Mar 04 08:46:33 2014 -0500
@@ -0,0 +1,3 @@
+task initialize = fn _ =>
+  v <- getenv (blessEnvVar "USER");
+  return {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/getenv.urp	Tue Mar 04 08:46:33 2014 -0500
@@ -0,0 +1,3 @@
+allow env USER
+
+getenv