changeset 504:dbdf4b8193a8

add Http.per_session()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 21 May 2015 01:09:35 -0600
parents 92c3d22745b8
children 7bc63886d4f2
files http/src/luan/modules/http/Http.luan http/src/luan/modules/http/HttpServicer.java http/src/luan/modules/http/shell.luan
diffstat 3 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
diff -r 92c3d22745b8 -r dbdf4b8193a8 http/src/luan/modules/http/Http.luan
--- a/http/src/luan/modules/http/Http.luan	Wed May 20 23:24:46 2015 -0600
+++ b/http/src/luan/modules/http/Http.luan	Thu May 21 01:09:35 2015 -0600
@@ -115,4 +115,12 @@
 -- request = new_request{}  -- filled in by HttpServicer
 -- response = new_response{}  -- filled in by HttpServicer
 
+
+M.per_session_pages = {}
+
+function M.per_session(page)
+	M.per_session_pages[page] = true
+end
+
+
 return M
diff -r 92c3d22745b8 -r dbdf4b8193a8 http/src/luan/modules/http/HttpServicer.java
--- a/http/src/luan/modules/http/HttpServicer.java	Wed May 20 23:24:46 2015 -0600
+++ b/http/src/luan/modules/http/HttpServicer.java	Thu May 21 01:09:35 2015 -0600
@@ -47,13 +47,15 @@
 	{
 		LuanFunction fn;
 		synchronized(luan) {
+			LuanTable module = (LuanTable)PackageLuan.require(luan,"luan:http/Http");
+			LuanTable per_session_pages = (LuanTable)module.rawGet("per_session_pages");
 			Object mod = PackageLuan.load(luan,modName);
 			if( mod==null )
 				return false;
 			if( !(mod instanceof LuanTable) )
 				throw luan.exception( "module '"+modName+"' must return a table" );
 			LuanTable tbl = (LuanTable)mod;
-			if( Boolean.TRUE.equals(tbl.get(luan,"per_session")) ) {
+			if( Boolean.TRUE.equals(per_session_pages.rawGet(mod)) ) {
 				HttpSession session = request.getSession();
 				LuanState sessionLuan  = (LuanState)session.getValue("luan");
 				if( sessionLuan!=null ) {
diff -r 92c3d22745b8 -r dbdf4b8193a8 http/src/luan/modules/http/shell.luan
--- a/http/src/luan/modules/http/shell.luan	Wed May 20 23:24:46 2015 -0600
+++ b/http/src/luan/modules/http/shell.luan	Thu May 21 01:09:35 2015 -0600
@@ -10,7 +10,7 @@
 
 local M = {}
 
-M.per_session = true
+Http.per_session(M)
 
 local history = {}
 M.env = {}