Ver Fonte

Change calls from table.get(key, default) by table.rawget(key, default) because the first can give wrong results when the key is equal to any built in methods.

mingodad há 12 anos atrás
pai
commit
17c9228573

+ 4 - 4
SquiLu-ourbiz/companies-uk.nut

@@ -11,9 +11,9 @@
 local globals = getroottable();
 
 local function getCompaniesUkDBFileName(){
-	if (globals.get("jniLog", false)) return APP_CODE_FOLDER + "/companies-uk-RG.db";
-	if (globals.get("WIN32", false)) return APP_CODE_FOLDER + "/../../companies-uk/companies-uk-RG.db";
-	return "/media/USBHD320/bo/uk/companies-uk-RG.db";
+	if (globals.rawget("jniLog", false)) return APP_CODE_FOLDER + "/companies-uk-RG.db";
+	if (globals.rawget("WIN32", false)) return APP_CODE_FOLDER + "/../../companies-uk/companies-uk-RG.db";
+	return APP_CODE_FOLDER + "/../../companies-uk/companies-uk-RG.db";
 }
 
 local companiesUkDB = null;
@@ -509,7 +509,7 @@ add_uri_hanlders({
 			foreach(k in filed_names) data[k] <-request.get_var(query_string, k);
 		}
 		else foreach(k in filed_names) data[k] <- null;
-		if(!data.get("page", null))  data.page <- 0;
+		if(!data.rawget("page", null))  data.page <- 0;
 		else data.page = data.page.tointeger();
 
 		local errcode;

+ 4 - 4
SquiLu-ourbiz/db-updater.nut

@@ -6,7 +6,7 @@
  
 local globals = getroottable();
 
-if(!globals.get("HTTPConn", false)) dofile("ourbiz-client.nut");
+if(!globals.rawget("HTTPConn", false)) dofile("ourbiz-client.nut");
 
 enum edbAction {e_none, e_insert, e_update, e_delete};
 
@@ -140,7 +140,7 @@ class DBTableUpdateBase {
 		httpRequest.send_my_request("POST", url, body_str, body_str.len(),
 					 useMultiPart ? boundary + 2 : 0, //+2 to discount "--"
 					 useSLE);
-		//local check_idle = globals.get("Fl", false);
+		//local check_idle = globals.rawget("Fl", false);
 		while( httpRequest.outstanding() )
 		{
 			httpRequest.pump();
@@ -155,7 +155,7 @@ class DBTableUpdateBase {
 			version = 0;
 			local rec = {};
 			appServer.asle2map(my_result, rec);
-			local new_id = rec.get("id", 0).tointeger();
+			local new_id = rec.rawget("id", 0).tointeger();
 			if(new_id == 0) throw("Could not update this record !");
 			edit_id = new_id;
 		}
@@ -165,7 +165,7 @@ class DBTableUpdateBase {
 		{
 			local rec = {};
 			appServer.sle2map(my_result, rec);
-			local changes = rec.get("changes", 0).tointeger();
+			local changes = rec.rawget("changes", 0).tointeger();
 			if(changes == 0) {
 				if(dbAction == edbAction.e_update) throw("Could not update this record !");
 				else throw("Could not delete this record !");

+ 41 - 41
SquiLu-ourbiz/fluid2SquiLu.nut

@@ -229,12 +229,12 @@ Write.Function <- function(t, ind){
 	t.varname <- "res";
 	Write.group(t.body, ind+1);
 	local names = [];
-	foreach(i in t.body) names.push(i.get("varname", null));
+	foreach(i in t.body) names.push(i.rawget("varname", null));
 	if (names.len() > 0) Output(ind+1, "return %s;\n", names.concat(", "));
 	Output(ind, "}\n\n");
 }
 
-function getClassNameOrKey(t){return  t.attr.get("class", false) || t.key;}
+function getClassNameOrKey(t){return  t.attr.rawget("class", false) || t.key;}
 
 Write.Atributes <- function(t, ind, name){
 	local lname;
@@ -258,11 +258,11 @@ Write.Atributes <- function(t, ind, name){
 
 Write.widget <- function(t, ind){
 	local fgroup = Grammar.groups.get(t.key, false);
-	if (Grammar.composed.get(t.key, false) && t.attr.get("type", false)){
+	if (Grammar.composed.get(t.key, false) && t.attr.rawget("type", false)){
 		t.key = t.key.slice(0,3) + t.attr.type + t.key.slice(2);
 		t.attr.type = null;
 	}
-	local klass = t.attr.get("class", false) || t.key;
+	local klass = t.attr.rawget("class", false) || t.key;
 	local constClearLabel = "_ClearLabel";
 	local isClearLabel = false;
 	if (klass.match(constClearLabel)){ 
@@ -273,8 +273,8 @@ Write.widget <- function(t, ind){
 	local ar = t.attr.xywh;
 	local x = ar[0], y = ar[1], w = ar[2], h = ar[3];
 	local name = configuration.currentvar;
-	t.xoffset <- t.parent.get("xoffset", "");
-	t.yoffset <- t.parent.get("yoffset", "");
+	t.xoffset <- t.parent.rawget("xoffset", "");
+	t.yoffset <- t.parent.rawget("yoffset", "");
 	local newMethodCallStr, firstParamStr;
 	if (klass.match("^fltk%.")) {
 		newMethodCallStr = "";
@@ -288,7 +288,7 @@ Write.widget <- function(t, ind){
 	//print(t.key, name, klass)
 	Output(ind, "{\n"); 
 	++ind;
-	local dirty_name =  t.attr.get("dirty_name", false);
+	local dirty_name =  t.attr.rawget("dirty_name", false);
 	local need_var_assign = true;
 	if(dirty_name && dirty_name[0] == '@'){
 		need_var_assign = false;
@@ -296,14 +296,14 @@ Write.widget <- function(t, ind){
 		Output(ind, "local o = %s;\n", dirty_name);
 		Output(ind, "Fl_Group.current()->add(o);\n", dirty_name);
 		Output(ind, "o->resize(%s%s%d, %s%d, %d, %d);\n",  firstParamStr, t.xoffset, x, t.yoffset, y, w, h);
-		if (! isClearLabel && t.attr.get("label", false)) 
+		if (! isClearLabel && t.attr.rawget("label", false)) 
 			Output(ind, "o->lable(%s(%q));\n", configuration.textfilter, t.attr.label);
 	}
 	else
 	{
 		Output(ind, "local %s = %s%s(%s%s%d, %s%d, %d, %d", name, 
 			klass, newMethodCallStr, firstParamStr, t.xoffset, x, t.yoffset, y, w, h);
-		if (! isClearLabel && t.attr.get("label", false)) Output(0, ", %s(%q)", configuration.textfilter, t.attr.label);
+		if (! isClearLabel && t.attr.rawget("label", false)) Output(0, ", %s(%q)", configuration.textfilter, t.attr.label);
 		Output(0, ");\n");
 	}	
 
@@ -336,19 +336,19 @@ Write.widget <- function(t, ind){
 	
 	Write.Atributes(t, ind, name);
 
-	local img = t.attr.get("image", false);
+	local img = t.attr.rawget("image", false);
 	if (img){
 		local ext = img.match("%.(%a+)$").toupper();
 		Output(ind, "%s.image(Fl_%s_Image(%q));\n", name, Grammar.images[ext], img);
 	}
-	if (t.attr.get("modal", false)) Output(ind, "%s.set_modal();\n", name);
-	if (t.attr.get("non_modal", false)) Output(ind, "%s.set_non_modal();\n", name);
+	if (t.attr.rawget("modal", false)) Output(ind, "%s.set_modal();\n", name);
+	if (t.attr.rawget("non_modal", false)) Output(ind, "%s.set_non_modal();\n", name);
 	for(local i=0; i <= 3; ++i){
-		local code = t.attr.get("code" + i, false);
+		local code = t.attr.rawget("code" + i, false);
 		if (code && code.len()) {
 			if(code[0] == '='){
 				code = code.slice(1);
-				local macro = t.attr.get("macro_name", false);
+				local macro = t.attr.rawget("macro_name", false);
 				if(macro){
 					macro = macro.split(' ');
 					code = code.gsub("$%((%d+)%)", function(m){
@@ -365,9 +365,9 @@ Write.widget <- function(t, ind){
 			else Output(ind, "%s\n", code);
 		}
 	}
-	if (t.attr.get("noborder", false)) Output(ind, "%s.clear_border();\n", name);
-	if (t.attr.get("size_range", false)) Output(ind, "%s.size_range(%s);\n", name, table.concat(t.attr.size_range, ", "));
-	local cb = t.attr.get("callback", false);
+	if (t.attr.rawget("noborder", false)) Output(ind, "%s.clear_border();\n", name);
+	if (t.attr.rawget("size_range", false)) Output(ind, "%s.size_range(%s);\n", name, table.concat(t.attr.size_range, ", "));
+	local cb = t.attr.rawget("callback", false);
 	if (cb){
 		if (cb.match("^[%w_]+$")) Output(ind, "%s.callback(%s);\n", name, cb);
 		else
@@ -377,7 +377,7 @@ Write.widget <- function(t, ind){
 			Output(ind, "});\n");
 		}
 	}
-	if (t.get("body", false) && t.body.len() > 0) {
+	if (t.rawget("body", false) && t.body.len() > 0) {
 		Output(ind, "{\n");
 		Write.group(t.body, ind+1);
 		Output(ind, "}\n");
@@ -387,18 +387,18 @@ Write.widget <- function(t, ind){
 		if (klass.match("^fltk%.")) Output(ind, "%s.end();\n", name);
 		else Output(ind, "%s.end();\n", name);
 	}
-	if (t.attr.get("resizable", false)) { 
+	if (t.attr.rawget("resizable", false)) { 
 		if (t.parent.key != "Function"){
 			Output(ind, "Fl_Group.current().resizable(%s);\n", name);
 			t.parent.resized <- true;
 		}
-		else if (! t.get("resized", false) ) Output(ind, "%s.resizable(%s);\n", name, name);
+		else if (! t.rawget("resized", false) ) Output(ind, "%s.resizable(%s);\n", name, name);
 	}
 	Output(ind-1, "}\n"); 
 }
 
 Write.Submenu <- function(t, ind){
-	if (t.parent.get("path", false)) t.path <- t.parent.path + "/" + t.attr.label;
+	if (t.parent.rawget("path", false)) t.path <- t.parent.path + "/" + t.attr.label;
 	else t.path <- t.attr.label;
 
 	Output(ind, "//%s %s\n", t.name, t.path);
@@ -407,13 +407,13 @@ Write.Submenu <- function(t, ind){
 }
 
 Write.MenuItem <- function(t, ind){
-	if (t.parent.get("path", false)) t.path <- t.parent.path + "/" +  t.attr.get("label", "");
+	if (t.parent.rawget("path", false)) t.path <- t.parent.path + "/" +  t.attr.rawget("label", "");
 	else t.path <- t.attr.label;
 
 	local w = t;
-	while (!w.get("varname", false)) w = w.parent;
+	while (!w.rawget("varname", false)) w = w.parent;
 
-	local cb = t.attr.get("callback", false);
+	local cb = t.attr.rawget("callback", false);
 	
 	if (!cb && t.name > ""){
 		//cb = "dispatch_func(" + t.name + "_cb, self)";
@@ -426,7 +426,7 @@ Write.MenuItem <- function(t, ind){
 		Output(ind, "o.add(%s(%q)", configuration.textfilter, t.path);
 	}
 
-	Output(0, ", %s", t.attr.get("shortcut", "0").tostring());
+	Output(0, ", %s", t.attr.rawget("shortcut", "0").tostring());
 	if (cb){
 		if (cb.match("^[%w_]+$")) Output(ind, ", %s", cb);
 		else
@@ -438,27 +438,27 @@ Write.MenuItem <- function(t, ind){
 
 		if (t.name > ""){
 			local ind2 = 0;
-			if (t.attr.get("deactivate", false)) Output2(ind2, "// deactivated base_class.%s\n", t.name);
+			if (t.attr.rawget("deactivate", false)) Output2(ind2, "// deactivated base_class.%s\n", t.name);
 			Output2(ind2, "function base_class.%s_cb(sender);\n", t.name);
 			Output2(ind2+2, "fl_alert(\"%s en construccion\");\n", t.name);
 			Output2(ind2, "}\n\n", t.name);
 		}
 	}
 	local type = null;
-	if(t.attr.get("type", false)) type = Grammar.menu_const[t.attr.type];
-	if (t.attr.get("divider", false)){ 
+	if(t.attr.rawget("type", false)) type = Grammar.menu_const[t.attr.type];
+	if (t.attr.rawget("divider", false)){ 
 		if (type) type = type + Grammar.menu_const.divider;
 		else type = Grammar.menu_const.divider;
 	}
-	if (t.attr.get("deactivate", false)){ 
+	if (t.attr.rawget("deactivate", false)){ 
 		if (type) type = type + Grammar.menu_const.deactivate;
 		else type = Grammar.menu_const.deactivate ;
 	}
-	if (t.attr.get("hide", false)) { 
+	if (t.attr.rawget("hide", false)) { 
 		if (type) type = type + Grammar.menu_const.hide;
 		else type = Grammar.menu_const.hide;
 	}
-	if (t.attr.get("value", false)){
+	if (t.attr.rawget("value", false)){
 		if (type) type = type + 4; // FL_MENU_VALUE = 4
 		else type = 4; // FL_MENU_VALUE = 4 
 	}
@@ -498,11 +498,11 @@ Write.decl <- function(t, ind){}
 Write.declblock <- function(t, ind){
 	Output(ind, "%s\n", t.name);
 	Write.group(t.body, ind+1);
-	Output(ind, "%s\n", t.attr.get("after", "}"));
+	Output(ind, "%s\n", t.attr.rawget("after", "}"));
 }
 
 Write["class"] <- function(t, ind){
-	Output(ind, "class %s extends %s {\n", t.name, t.get("class", "?"));
+	Output(ind, "class %s extends %s {\n", t.name, t.rawget("class", "?"));
 	local vars = [];
 	FindMembers.group(t.body, vars);
 	WriteVariables(ind+1, vars, "class members");
@@ -517,9 +517,9 @@ Write.widget_class <- function(t, ind){
 	local vars = [];
 	local wObj = "";
 	local typeName;
-	//if (t.attr.get("class", false) && t.attr["class"].match("^Fl_")) typeName = "fltk." + t.attr["class"];
+	//if (t.attr.rawget("class", false) && t.attr["class"].match("^Fl_")) typeName = "fltk." + t.attr["class"];
 	//else  
-	typeName = t.attr.get("class", "Fl_Group");
+	typeName = t.attr.rawget("class", "Fl_Group");
 
 	local widgetType = typeName;
 	Output(ind, "class %s extends %s {\n", t.name, widgetType);
@@ -530,13 +530,13 @@ Write.widget_class <- function(t, ind){
 	
 	local ar = t.attr.xywh;
 	local x = ar[0], y = ar[1], w = ar[2], h = ar[3];
-	local wlabel = t.attr.get("label", false);
+	local wlabel = t.attr.rawget("label", false);
 
 	local strCreateWidget = format("constructor(px=%d, py=%d, pw=%d, ph=%d, pl=%s){\n",
 		x, y, w, h, wlabel ? format( "%s(%q)", configuration.textfilter, wlabel): "null");
 	Output(ind+1, strCreateWidget);
 	Output(ind+2, "base.constructor(px, py, pw, ph, pl);\n");
-	if (! (t.attr.get("class", "")).match("_Window$") ) {
+	if (! (t.attr.rawget("class", "")).match("_Window$") ) {
 		t.xoffset <- "_x + ";
 		t.yoffset <- "_y + ";
 		Output(ind+2, "local _x = %d, _y = %d;\n", x, y);
@@ -578,7 +578,7 @@ FindMembers.Function <- function(t, list){
 }
 
 FindMembers["class"] <- function(t, list){
-	list.push([ t.name, "public", t.attr.get("class", "null") ]);
+	list.push([ t.name, "public", t.attr.rawget("class", "null") ]);
 }
 
 FindMembers.widget_class <- FindMembers["class"];
@@ -590,7 +590,7 @@ FindMembers.widget <- function(t, list){
 	else if (t.name.match("^[%w_]+$")){
 		list.push([ t.name, GetAccessMode(t, "public") , getClassNameOrKey(t)]);
 	}
-	if (t.get("body", false)) FindMembers.group(t.body, list);
+	if (t.rawget("body", false)) FindMembers.group(t.body, list);
 }
 
 FindMembers.decl <- function(t, list){
@@ -605,7 +605,7 @@ FindMembers.submenu <- function(t, list){
 				//print("body", k2, v2);
 				if(type(v2) == "table"){
 					//foreach(k3,v3 in v2) print("menuitem", k3,v3);
-					if(v2.get("name", false)) list.push([ v2.name, GetAccessMode(t, "public"), getClassNameOrKey(t)]);
+					if(v2.rawget("name", false)) list.push([ v2.name, GetAccessMode(t, "public"), getClassNameOrKey(t)]);
 				}
 			}
 		}
@@ -735,7 +735,7 @@ function mydebughook(event_type,sourcefile,line,funcname)
 			else print(k,v);
 		}
 */
-		local pos = getstackinfos(2).locals.get("pos", false);
+		local pos = getstackinfos(2).locals.rawget("pos", false);
 		if(isDebugging || pos == 8926) {
 			foreach(k,v in getstackinfos(2)) {
 				if(type(v) == "table") {

+ 1 - 1
SquiLu-ourbiz/happyhttp.nut

@@ -199,7 +199,7 @@ class HappyHttpConnection {
 		// check headers for content-length
 		// TODO: check for "Host" and "Accept-Encoding" too
 		// and avoid adding them ourselves in putrequest()
-		if( headers ) gotcontentlength = headers.get("content-length", false);
+		if( headers ) gotcontentlength = headers.rawget("content-length", false);
 
 		putrequest( method, url );
 

+ 88 - 88
SquiLu-ourbiz/ourbiz.nut

@@ -188,13 +188,13 @@ const C_zip = "zip";
 // generated-code:end 
 
 local globals = getroottable();
-if(!globals.get("APP_CODE_FOLDER", false)) ::APP_CODE_FOLDER <- ".";
+if(!globals.rawget("APP_CODE_FOLDER", false)) ::APP_CODE_FOLDER <- ".";
 
 local constants = getconsttable();
 
 local function getOurbizDBFileName(){
-	if(globals.get("jniLog", false)) return APP_CODE_FOLDER + "/ourbiz.db";
-	if(globals.get("WIN32", false)) return APP_CODE_FOLDER + "/../../ourbiz-uk/ourbiz.db";
+	if(globals.rawget("jniLog", false)) return APP_CODE_FOLDER + "/ourbiz.db";
+	if(globals.rawget("WIN32", false)) return APP_CODE_FOLDER + "/../../ourbiz-uk/ourbiz.db";
 	return "/home/mingo/dev/FrontAccountLua/ourbiz.db";
 }
 
@@ -205,7 +205,7 @@ local function getOurbizDB(){
 	//return checkCachedDB(APP_CODE_FOLDER + "/ourbiz.db");
 }
 
-if(globals.get("AT_DEV_DBG", false) || !globals.get("PdfSqlTable", false)) {
+if(globals.rawget("AT_DEV_DBG", false) || !globals.rawget("PdfSqlTable", false)) {
 	dofile(APP_CODE_FOLDER + "/pdf-table.nut");
 }
 
@@ -224,7 +224,7 @@ local function escape_sql_like_search_str(str){
 local function mkEmptyWhenZero(tbl, key){
 	if (type(key) == "array"){
 		foreach( v in key ) {
-			if (tbl.get(v, false) == "0") tbl[v] = "";
+			if (tbl.rawget(v, false) == "0") tbl[v] = "";
 		}
 	}
 	else if (tbl[key] == 0) tbl[key] = "";
@@ -333,17 +333,17 @@ local function get_sql_bar_chart_statistics_periodes (periode_count, periode_typ
 
 local function getOptionsFromMap(map){
 	local opt = {};
-	opt.search_str <- map.get("search_str", null);
-	opt.select_fields <- map.get("select_fields", null);
-	opt.search_on <- map.get("search_on", "1"); //to make easy on html interface
+	opt.search_str <- map.rawget("search_str", null);
+	opt.select_fields <- map.rawget("select_fields", null);
+	opt.search_on <- map.rawget("search_on", "1"); //to make easy on html interface
 	local CHECK_BOOL = function(field){
-		local value = map.get(field, null);
+		local value = map.rawget(field, null);
 		if (value == "1") opt[field] <- "1";
 		else opt[field] <- null;
 	}
 	local math_floor = math.floor;
 	local CHECK_INT_DFLT = function(field, dflt) {
-		local value = map.get(field, dflt).tointeger();
+		local value = map.rawget(field, dflt).tointeger();
 		opt[field] <- math_floor(value);
 	}
 	local CHECK_INT = function(field) {CHECK_INT_DFLT(field, 0) };
@@ -385,7 +385,7 @@ local function getOptionsFromMap(map){
 }
 
 local function checkQueryStringSAB(qs_tbl, so=null){
-	local qs_sab = qs_tbl.get("sab", null);
+	local qs_sab = qs_tbl.rawget("sab", null);
 	if (qs_sab){
 		if (qs_sab == "S") {
 			if(so) so.sales <- true;
@@ -403,7 +403,7 @@ local function checkQueryStringSAB(qs_tbl, so=null){
 local function get_search_options(req){
 	local search_opt = getOptionsFromMap(req);
 
-	local sab = req.get("sab", null);
+	local sab = req.rawget("sab", null);
 	if (sab && sab.len() > 0){
 		local c = sab.toupper();
 		if (c == "S") search_opt.sales <- true;
@@ -439,7 +439,7 @@ local DB_Manager = class {
 		mf.write("insert into ", table_name,  "(")
 		local isFirst = true;
 		foreach( k,v in editable_fields) {
-			if (data.get(v, false)){
+			if (data.rawget(v, false)){
 				if (isFirst) isFirst = false;
 				else mf.write(",");
 				mf.write(v);
@@ -448,7 +448,7 @@ local DB_Manager = class {
 		mf.write(") values(");
 		isFirst = true;
 		foreach( k,v in editable_fields) {
-			if (data.get(v, false)){
+			if (data.rawget(v, false)){
 				if (isFirst) isFirst = false;
 				else mf.write(",");
 				mf.write("?");
@@ -459,7 +459,7 @@ local DB_Manager = class {
 		local stmt = db.prepare(mf.tostring());
 		local x = 0;
 		foreach( k,v in editable_fields) {
-			if (data.get(v, false)){
+			if (data.rawget(v, false)){
 				stmt.bind_empty_null(++x, data[v]);
 			}
 		}
@@ -474,7 +474,7 @@ local DB_Manager = class {
 		mf.write("update ", table_name,  " set ");
 		local isFirst = true;
 		foreach( k,v in editable_fields) {
-			if (data.get(v, false)){
+			if (data.rawget(v, false)){
 				if (isFirst) isFirst = false;
 				else mf.write(",");
 				mf.write(v, "=?");
@@ -488,7 +488,7 @@ local DB_Manager = class {
 		local stmt = db.prepare(mf.tostring());
 		local x = 0;
 		foreach( k,v in editable_fields) {
-			if (data.get(v, false)) {
+			if (data.rawget(v, false)) {
 				stmt.bind_empty_null(++x, data[v]);
 			}
 		}
@@ -557,13 +557,13 @@ WHERE entity_id = ]==], aId);
 	}
 	
 	function save_image (db, tbl_qs, tbl, sle_buf)                                                                              {
-		local thumbnail = tbl_qs.get("thumbnail", null);
+		local thumbnail = tbl_qs.rawget("thumbnail", null);
 		if(thumbnail)
 		{
-			local image = tbl_qs.get("image", null);
-			local mime_type = tbl_qs.get("mime_type", null);
+			local image = tbl_qs.rawget("image", null);
+			local mime_type = tbl_qs.rawget("mime_type", null);
 
-			local id = tbl_qs.get("__id__", 0);
+			local id = tbl_qs.rawget("__id__", 0);
 			local isNewRecord = id == 0;
 			if(isNewRecord) id = db.last_row_id(); //new record get last_insert_rowid
 			if(id)
@@ -1537,30 +1537,30 @@ local DB_Entities = class extends DB_Manager {
 
 	function sql_list(qs_tbl, post_tbl){
 		local entity_id;
-		if (qs_tbl.get("search", false)) return entities_sql_search_list(qs_tbl, post_tbl);
-		else if (qs_tbl.get("past_products", false)) return entity_past_products_get_sql(qs_tbl.past_products.tointeger());
-		else if ( (entity_id = qs_tbl.get("history", 0)) ){
-			local htype = qs_tbl.get("htype", 0);
+		if (qs_tbl.rawget("search", false)) return entities_sql_search_list(qs_tbl, post_tbl);
+		else if (qs_tbl.rawget("past_products", false)) return entity_past_products_get_sql(qs_tbl.past_products.tointeger());
+		else if ( (entity_id = qs_tbl.rawget("history", 0)) ){
+			local htype = qs_tbl.rawget("htype", 0);
 			local query_limit = qs_tbl.get(C_query_limit, 50).tointeger();
 			return entity_sales_history_sql(htype, query_limit, entity_id.tointeger());
 		}
-		else if ( (entity_id = qs_tbl.get("statistics", 0)) ){
+		else if ( (entity_id = qs_tbl.rawget("statistics", 0)) ){
 			local periode_count = qs_tbl.get(C_periode_count, 12).tointeger();
 			local periode_type = getStatisticsPeriodeType(qs_tbl.get(C_periode_type, C_months));
-			local sab = qs_tbl.get("sab", "S");
+			local sab = qs_tbl.rawget("sab", "S");
 			return entity_bar_chart_statistics_sql(entity_id.tointeger(), sab, periode_count, periode_type);
 		}
-		else if (qs_tbl.get("print_list", false)){
+		else if (qs_tbl.rawget("print_list", false)){
 			return entities_list_sql();
 		}
-		else if (qs_tbl.get("pdf", false)){
+		else if (qs_tbl.rawget("pdf", false)){
 			qs_tbl._doc_pdf_ <- get_pdf_list(qs_tbl);
 			return true;
 		}
 	}
 	
 	function get_pdf_list(tbl_qs){
-		local clipped = tbl_qs.get("clipped", false);
+		local clipped = tbl_qs.rawget("clipped", false);
 		local pdf = new PdfSqlTable();
 		pdf.page_title = "Entities List";
 		pdf.water_mark = "T H I S   I S   A   D E M O";
@@ -1580,18 +1580,18 @@ order by name
 
 	function sql_get_one(tbl_qs){
 		local id = tbl_qs.get(table_name, 0).tointeger();
-		if(tbl_qs.get("for_order", false))
+		if(tbl_qs.rawget("for_order", false))
 		{
 			return entity_for_order_get_one(id);
 		}
-		else if(tbl_qs.get("with_thumbnail", false))
+		else if(tbl_qs.rawget("with_thumbnail", false))
 		{
 			return [==[
 select e.*, i.thumbnail, i.mime_type
 from entities e left join images i
 on e.image_id = i.id where e.id=?]==];
 		}
-		else if(tbl_qs.get("pdf", false))
+		else if(tbl_qs.rawget("pdf", false))
 		{
 			return get_pdf_list(tbl_qs);
 		}
@@ -1614,7 +1614,7 @@ db_ourbiz_tables.entities <- new DB_Entities();
 // orders
 //
 
-if(globals.get("AT_DEV_DBG", false) || !globals.get("PDF_Order", false)) {
+if(globals.rawget("AT_DEV_DBG", false) || !globals.rawget("PDF_Order", false)) {
 	dofile(APP_CODE_FOLDER + "/pdf-order.nut");
 }
 
@@ -2145,32 +2145,32 @@ local DB_Orders = class extends DB_Manager {
 
 	function sql_list(qs_tbl, post_tbl){
 		local order_id
-		if (qs_tbl.get("search", false)) return orders_sql_search_list(qs_tbl, post_tbl);
-		else if( (order_id = qs_tbl.get("lines", 0)) )
+		if (qs_tbl.rawget("search", false)) return orders_sql_search_list(qs_tbl, post_tbl);
+		else if( (order_id = qs_tbl.rawget("lines", 0)) )
 		{
 			return orders_lines_sql_for_order(order_id.tointeger());
 		}
-		else if(  (order_id = qs_tbl.get("sum", 0)) )
+		else if(  (order_id = qs_tbl.rawget("sum", 0)) )
 		{
-			local query_limit = qs_tbl.get("query_limit", 50);
+			local query_limit = qs_tbl.rawget("query_limit", 50);
 			return orders_sum_search_sql(query_limit);
 		}
-		else if( (order_id = qs_tbl.get("lines_onhand", 0)) )
+		else if( (order_id = qs_tbl.rawget("lines_onhand", 0)) )
 		{
 			return order_lines_onhand_get_sql(order_id.tointeger());
 		}		
-		else if (qs_tbl.get("history", false)){
-			local htype = qs_tbl.get("htype", 0).tointeger();
-			local query_limit = qs_tbl.get("query_limit", 50).tointeger();
+		else if (qs_tbl.rawget("history", false)){
+			local htype = qs_tbl.rawget("htype", 0).tointeger();
+			local query_limit = qs_tbl.rawget("query_limit", 50).tointeger();
 			return orders_sales_history_sql(htype, query_limit, qs_tbl.history);
 		}
-		else if (qs_tbl.get("statistics", false)){
+		else if (qs_tbl.rawget("statistics", false)){
 			local periode_count = qs_tbl.get(C_periode_count, 12).tointeger();
-			local periode_type = getStatisticsPeriodeType(qs_tbl.get("periode_type", "months"));
-			local sab = qs_tbl.get("sab", "S");
+			local periode_type = getStatisticsPeriodeType(qs_tbl.rawget("periode_type", "months"));
+			local sab = qs_tbl.rawget("sab", "S");
 			return sql_bar_chart_statistics(sab, periode_count, periode_type);
 		}
-		else if (qs_tbl.get("print_list", false)){
+		else if (qs_tbl.rawget("print_list", false)){
 		}
 	}
 
@@ -2178,7 +2178,7 @@ local DB_Orders = class extends DB_Manager {
 	{
 		_calc_line.reset();
 		local product_id = tbl_qs.get(C_product_id, 0).tointeger();
-		local order_id = tbl_qs.get("__id__", 0).tointeger();
+		local order_id = tbl_qs.rawget("__id__", 0).tointeger();
 		if(product_id  && order_id)
 		{
 			local db = getOurbizDB();
@@ -2268,11 +2268,11 @@ where o.id = %d and p.id = %d]==], order_id, product_id));
 	
 	function sql_get_one(tbl_qs) {
 		local id = tbl_qs.get(table_name, 0).tointeger();
-		if(tbl_qs.get("line", false))
+		if(tbl_qs.rawget("line", false))
 		{
 			orders_lines_get_one(id);
 		}
-		else if(tbl_qs.get("line_calculated", false))
+		else if(tbl_qs.rawget("line_calculated", false))
 		{
 			local db = getOurbizDB();
 			local stmt = db.prepare(orders_lines_get_one(id));
@@ -2283,7 +2283,7 @@ where o.id = %d and p.id = %d]==], order_id, product_id));
 			calc_order_line(tbl_qs, buf, rec_map);
 			return buf;
 		}
-		else if (tbl_qs.get("with_lines", false)){
+		else if (tbl_qs.rawget("with_lines", false)){
 			local db = getOurbizDB();
 			local buf = blob(0, 8192);
 
@@ -2310,7 +2310,7 @@ where o.id = %d and p.id = %d]==], order_id, product_id));
 			buf.write(stmt.asSleArray());
 			return buf;
 		}
-		else if (tbl_qs.get("pdf", false)){
+		else if (tbl_qs.rawget("pdf", false)){
 			local db = getOurbizDB();
 			local calc_order = new MyCalcOrderTotals(db);
 			tbl_qs._doc_pdf_ <- calc_order.getPdfOrder(id, "en");
@@ -2321,7 +2321,7 @@ where o.id = %d and p.id = %d]==], order_id, product_id));
 
 	function db_action(db, data){
 		//dbg_dump_map(p.post_map);
-		local action = data.get("__action__", false);
+		local action = data.rawget("__action__", false);
 
 		if(action == "calc_line" || action == "calc_order_line")
 		{
@@ -2331,8 +2331,8 @@ where o.id = %d and p.id = %d]==], order_id, product_id));
 		}
 		else if(action == "order_numbering")
 		{
-			local order_id = data.get("__id__", 0).tointeger();
-			local version = data.get("__version__", 0).tointeger();
+			local order_id = data.rawget("__id__", 0).tointeger();
+			local version = data.rawget("__version__", 0).tointeger();
 			db.exec_dml("begin;");
 			try {
 				if(db.exec_dml(orders_numbering_get_sql(order_id, version)) < 1)
@@ -2363,9 +2363,9 @@ where o.id = %d and p.id = %d]==], order_id, product_id));
 
 	function do_db_action2(db, data){
 /*
-		local action = data.get("__action__", false);
-		local order_id = data.get("__id__", 0).tointeger();
-		local version = data.get("__version__", 0).tointeger();
+		local action = data.rawget("__action__", false);
+		local order_id = data.rawget("__id__", 0).tointeger();
+		local version = data.rawget("__version__", 0).tointeger();
 		
 		local line_id, entity_id, order_type_id, changes = 0;
 		map_str_t order_type_map;
@@ -2730,7 +2730,7 @@ local DB_Products = class extends DB_Manager {
 	}
 	
 	function getPdfList(qs_tbl){
-		local clipped = qs_tbl.get("clipped", false);
+		local clipped = qs_tbl.rawget("clipped", false);
 		local pdf = new PdfSqlTable();
 		pdf.page_title = "Products List";
 		pdf.water_mark = "T H I S   I S   A   D E M O";
@@ -2745,26 +2745,26 @@ local DB_Products = class extends DB_Manager {
 
 	function sql_list(qs_tbl, post_tbl){
 		local product_id;
-		if (qs_tbl.get("search", false)) return products_sql_search_list(qs_tbl, post_tbl);
-		else if ( (product_id = qs_tbl.get("prices_by_quantity", 0)) ) return product_prices_list_sql(product_id.tointeger());
-		else if ( (product_id = qs_tbl.get("past_products", 0)) ) return entity_past_products_get_sql(product_id.tointeger());
-		else if ( (product_id = qs_tbl.get("last_order_lines", 0)) ) return last_product_order_lines_get_sql(product_id.tointeger());
-		else if ( (product_id = qs_tbl.get("appear_together", 0)) ) return product_appear_together_get_sql(product_id.tointeger());
-		else if ( (product_id = qs_tbl.get("history", 0)) ) {
-			local htype = qs_tbl.get("htype", 0).tointeger();
+		if (qs_tbl.rawget("search", false)) return products_sql_search_list(qs_tbl, post_tbl);
+		else if ( (product_id = qs_tbl.rawget("prices_by_quantity", 0)) ) return product_prices_list_sql(product_id.tointeger());
+		else if ( (product_id = qs_tbl.rawget("past_products", 0)) ) return entity_past_products_get_sql(product_id.tointeger());
+		else if ( (product_id = qs_tbl.rawget("last_order_lines", 0)) ) return last_product_order_lines_get_sql(product_id.tointeger());
+		else if ( (product_id = qs_tbl.rawget("appear_together", 0)) ) return product_appear_together_get_sql(product_id.tointeger());
+		else if ( (product_id = qs_tbl.rawget("history", 0)) ) {
+			local htype = qs_tbl.rawget("htype", 0).tointeger();
 			local query_limit = qs_tbl.get(C_query_limit, 50).tointeger();
 			return product_sales_history_sql(htype, query_limit, product_id.tointeger());
 		}
-		else if ( (product_id = qs_tbl.get("statistics", 0)) ){
+		else if ( (product_id = qs_tbl.rawget("statistics", 0)) ){
 			local periode_count = qs_tbl.get(C_periode_count, 12).tointeger();
 			local periode_type = getStatisticsPeriodeType(qs_tbl.periode_type);
-			local sab = qs_tbl.get("sab", "S");
+			local sab = qs_tbl.rawget("sab", "S");
 			return product_bar_chart_statistics_sql(product_id.tointeger(), sab, periode_count, periode_type);
 		}
-		else if (qs_tbl.get("print_list", false)){
+		else if (qs_tbl.rawget("print_list", false)){
 			return products_list_sql();
 		}
-		else if (qs_tbl.get("pdf", false)){
+		else if (qs_tbl.rawget("pdf", false)){
 			return getPdfList(qs_tbl);
 		}
 	}
@@ -2780,23 +2780,23 @@ where p.id=?]==];
 	function sql_get_one(tbl_qs) {
 		local id = tbl_qs.get(table_name, 0).tointeger();
 		
-		if(tbl_qs.get("discount_by_quantity", false))
+		if(tbl_qs.rawget("discount_by_quantity", false))
 		{
 			local quantity = tbl_qs.get(C_quantity, 0);
 			if(!quantity) return;
 			return discount_by_quantity_get_one(id, quantity);
 		}
-		else if(tbl_qs.get("price_for_calc", false))
+		else if(tbl_qs.rawget("price_for_calc", false))
 		{
 			return get_one_record_sql( _table_name, id,
                                 "buy_price, buy_discount, buy_other_costs, sell_price, price_decimals");
 		}
-		else if (tbl_qs.get("product_for_edit", false)){
+		else if (tbl_qs.rawget("product_for_edit", false)){
 			local db = getOurbizDB();
 			local buf = blob(0, 8192);
 			local sql;
 			
-			if(tbl_qs.get("with_thumbnail", false)){
+			if(tbl_qs.rawget("with_thumbnail", false)){
 				sql = getOneSqlWithThumbnail();
 			} else {
 				sql = base.sql_get_one(tbl_qs)
@@ -2821,7 +2821,7 @@ where p.id=?]==];
 
 			return buf;
 		}
-		else if(tbl_qs.get("product_aux_data", false))
+		else if(tbl_qs.rawget("product_aux_data", false))
 		{
 			local db = getOurbizDB();
 			local buf = blob(0, 8192);
@@ -2837,11 +2837,11 @@ where p.id=?]==];
 
 			return buf;
 		}
-		else if(tbl_qs.get("pdf", false))
+		else if(tbl_qs.rawget("pdf", false))
 		{
 			return getPdfList(qs_tbl);
 		}
-		else if(tbl_qs.get("with_thumbnail", false)){
+		else if(tbl_qs.rawget("with_thumbnail", false)){
 			return getOneSqlWithThumbnail().replace("?", id.tostring());
 		}
 		else return base.sql_get_one(tbl_qs);
@@ -2849,10 +2849,10 @@ where p.id=?]==];
 
 	function db_action(db, data)
 	{
-		local str = data.get("__action__", false);
+		local str = data.rawget("__action__", false);
 		if(str == "calc_price_by_quantity")
 		{
-			local id = data.get("__id__", 0);
+			local id = data.rawget("__id__", 0);
 			if(!id) return;
 
 			_calc_prices.clear();
@@ -2937,7 +2937,7 @@ local DB_Images = class extends DB_Manager {
 	function sql_get_one(req){
 		local mf = blob();
 		mf.write("select id, _version_, mime_type, name, description, group_set, cdate, mdate, length(image) as img_size ");
-		if (req.get("image_and_size", false)) mf.write(", image ");
+		if (req.rawget("image_and_size", false)) mf.write(", image ");
 		mf.write("from ", table_name ," where id=?");
 		return  mf.tostring();
 	}
@@ -2955,9 +2955,9 @@ local DB_order_types = class extends DB_Manager {
 	}
 
 	function sql_list(qs_tbl, post_tbl){
-		if (qs_tbl.get("short_list", false)){
+		if (qs_tbl.rawget("short_list", false)){
 			local sql = "select id, description from order_types where is_active = 1 ";
-			local group_order = qs_tbl.get("group_order", false);
+			local group_order = qs_tbl.rawget("group_order", false);
 			if (group_order && (group_order == "S" || group_order == "B")){
 				sql = format("%s and group_order='%s' ", sql, group_order);
 			}
@@ -3134,14 +3134,14 @@ local function ourbizDbGetList(request){
 	if (query_string){
 		local db = getOurbizDB();
 		local qs_tbl = parse_qs_to_table(query_string);
-		local list = qs_tbl.get("list", null);
-		local sab = qs_tbl.get("sab", "S");
+		local list = qs_tbl.rawget("list", null);
+		local sab = qs_tbl.rawget("sab", "S");
 		local isPost = request.info.request_method == "POST";
 		local sql, post_tbl, data;
 		if (isPost) post_tbl = get_post_fields(request, 1024);
 		else post_tbl = {};
 
-		if (!post_tbl.get("query_limit", false)) post_tbl.query_limit <- 50;
+		if (!post_tbl.rawget("query_limit", false)) post_tbl.query_limit <- 50;
 		gmFile.clear();
 
 		if (list == "entity_groups") db_ourbiz_tables.entity_groups.get_list(db, gmFile);
@@ -3149,7 +3149,7 @@ local function ourbizDbGetList(request){
 		else if (list == "config") sql = "select id, key,value from config";
 		else if (db_ourbiz_tables.get(list, false)){
 			sql = db_ourbiz_tables[list].sql_list(qs_tbl, post_tbl);
-			local doc_pdf = qs_tbl.get("_doc_pdf_", false);
+			local doc_pdf = qs_tbl.rawget("_doc_pdf_", false);
 			if (doc_pdf){
 				request.print(format([==[
 HTTP/1.1 200 OK
@@ -3201,7 +3201,7 @@ local function ourbizDbGetOne(request){
 		if (tbl == "config") sql = "select * from config where id=?";
 		else if (db_ourbiz_tables.get(tbl, false)) sql = db_ourbiz_tables[tbl].sql_get_one(tbl_qs);
 		
-		local doc_pdf = tbl_qs.get("_doc_pdf_", false);
+		local doc_pdf = tbl_qs.rawget("_doc_pdf_", false);
 		if (doc_pdf){
 			request.print(format([==[
 HTTP/1.1 200 OK
@@ -3279,8 +3279,8 @@ local function ourbizDbAction(request) {
 	if (isPost){
 		local data = get_post_fields(request, 10*1024);
 		local db = getOurbizDB();
-		local tbl = data.get("__table__", null);
-		local action = data.get("__action__", null);
+		local tbl = data.rawget("__table__", null);
+		local action = data.rawget("__action__", null);
 		local result;
 		//debug_print(tbl, "\n", action, "\n", data.__id__, "\n")
 		gmFile.clear();

+ 3 - 3
SquiLu-ourbiz/search-options.nut

@@ -92,9 +92,9 @@ class OurBizSearchOptions
 
     function getOptionsFromMap(map)
     {
-        search_str = map.get("search_str", "");
-        select_fields = map.get("select_fields", "");
-        search_on = map.get("search_on", "1");
+        search_str = map.rawget("search_str", "");
+        select_fields = map.rawget("select_fields", "");
+        search_on = map.rawget("search_on", "1");
 
 	foreach(k,v in this){
 		local ktype = type(v);

+ 52 - 33
SquiLu-ourbiz/sq-server-plugin.nut

@@ -5,7 +5,7 @@
  */
  
 local globals = getroottable();
-if(!globals.get("APP_CODE_FOLDER", false)) ::APP_CODE_FOLDER <- ".";
+if(!globals.rawget("APP_CODE_FOLDER", false)) ::APP_CODE_FOLDER <- ".";
 WIN32 <- os.getenv("WINDIR") != null;
 
 //local AT_DEV_DBG=true;
@@ -14,11 +14,11 @@ WIN32 <- os.getenv("WINDIR") != null;
 //local EDIT_MD5_PASSWORD = md5("edit_user:r.dadbiz.es:okdoedit");
 //local VIEW_MD5_PASSWORD = md5("view_user:r.dadbiz.es:okdoview");
 
-if(!globals.get("gmFile", false)) ::gmFile <- blob();
-if(!globals.get("__tplCache", false)) ::__tplCache <- {};
+if(!globals.rawget("gmFile", false)) ::gmFile <- blob();
+if(!globals.rawget("__tplCache", false)) ::__tplCache <- {};
 
 function getTemplate(fname, nocache){
-	local mixBase = ::__tplCache.get(fname, false);
+	local mixBase = ::__tplCache.rawget(fname, false);
 	if (!mixBase || nocache){
 		local rfn = format("%s/%s", APP_CODE_FOLDER, fname);
 		//debug_print("\n", rfn);
@@ -33,9 +33,9 @@ function getTemplate(fname, nocache){
 }
 
 /*
-if(!globals.get("__stmtCache", false)) ::__stmtCache <- {};
+if(!globals.rawget("__stmtCache", false)) ::__stmtCache <- {};
 function getCachedStmt(db, stmt_key, sql_or_func){
-	local stmt = ::__stmtCache.get(stmt_key, false);
+	local stmt = ::__stmtCache.rawget(stmt_key, false);
 	if (!stmt){
 		//local db =checkCompaniesUkDB()
 		local sql;
@@ -90,7 +90,7 @@ function split_filename(path){
 }
 
 function insert_field (dest, key, value){
-  local fld = dest.get(key, null);
+  local fld = dest.rawget(key, null);
   if (!fld) dest[key] <- value;
   else
   {
@@ -100,14 +100,16 @@ function insert_field (dest, key, value){
 }
 
 function multipart_data_get_field_names(headers, name_value){
+  //foreach(k,v in headers) debug_print(k, "::", v, "\n");
   local disp_header = headers["content-disposition"] || "";
   local attrs = {};
   disp_header.gmatch(";%s*([^%s=]+)=\"(.-)\"", function(attr, val) {
 	attrs[attr] <- val;
+	//debug_print(attr, "::", val, "\n");
 	return true;
   });
-  name_value[0] = attrs.name;
-  name_value[1] = attrs.filename ? split_filename(attrs.filename) : null;
+  name_value.push(attrs.name);
+  name_value.push(attrs.rawget("filename", false) ? split_filename(attrs.filename) : null);
 }
 
 function multipart_data_break_headers(header_data){
@@ -121,12 +123,12 @@ function multipart_data_break_headers(header_data){
 
 function multipart_data_read_field_headers(input, state){
 	local s, e, pos = state.pos;
-	input.lua_find("\r\n\r\n", function(start, end){s=start; e=end; return false;}, pos, true);
+	input.find_lua("\r\n\r\n", function(start, end){s=start; e=end; return false;}, pos, true);
 	if( s ) {
-		state.pos = e+1;
-		return multipart_data_break_headers(input.slice(pos, s-1));
+		state.pos <- e;
+		return multipart_data_break_headers(input.slice(pos, s));
 	}
-	else return nil;
+	else return null;
 }
 
 function multipart_data_read_field_contents(input, state){
@@ -134,20 +136,20 @@ function multipart_data_read_field_contents(input, state){
 	local s, e, pos = state.pos;
 	input.find_lua(boundaryline, function(start, end){ s=start; e=end; return false;}, pos, true)
 	if (s) {
-		state.pos = e+1;
-		state.size = s-pos;
-		return input.slice(pos, s-1);
+		state.pos <- e;
+		state.size <- s-pos;
+		return input.slice(pos, s);
 	}
 	else {
-		state.size = 0;
-		return nil;
+		state.size <- 0;
+		return null;
 	}
 }
 
 function multipart_data_file_value(file_contents, file_name, file_size, headers){
   local value = { contents = file_contents, name = file_name, size = file_size };
   foreach( h, v in headers) {
-	if (h != "content-disposition") value[h] = v;
+	if (h != "content-disposition") value[h] <- v;
   }
   return value;
 }
@@ -182,8 +184,8 @@ function multipart_data_get_boundary(content_type){
 function parse_multipart_data(input, input_type, tab=null){
 	if(!tab) tab = {};
 	local state = {};
-	state.boundary <- get_boundary(input_type);
-	input.find_lua(state.boundary, function(start, end){state.pos = end+1;return false;}, 0, true);
+	state.boundary <- multipart_data_get_boundary(input_type);
+	input.find_lua(state.boundary, function(start, end){state.pos <- end+1;return false;}, 0, true);
 	while(true){
 		local name_value = multipart_data_parse_field(input, state);
 		if(!name_value) break;
@@ -264,17 +266,34 @@ function get_post_fields(request, max_len=1024*1000){
 	if (data_len > 0 && data_len <= max_len) {
 		local content_type = request.get_header("Content-Type") || "x-www-form-urlencoded";
 		local data = request.read(data_len);
+		
 /*
-		local fd = file("post.txt", "wb");
+		local fd = file(::APP_CODE_FOLDER + "/post.txt", "wb");
 		fd.write(data, data.len());
 		fd.close();
-		debug_print(conn_get_header("Content-Type"), "\n");
+		debug_print(request.get_header("Content-Type"), "\n");
 */
+		if(content_type == "application/json; charset=UTF-8"){
+			return data;
+		}
 		parse_post_data(content_type, data, post_fields);
 	}
 	return post_fields;
 }
 
+local allowedUploadFileExtensions = {
+	[".png"] = "image/png",
+	[".jpg"] = "image/jpeg",
+	[".gif"] = "image/gif",
+}
+
+function getMimeType(fname){
+	local ext;
+	fname.gmatch("(%.?[^%.\\/]*)$", @(m) ext=m);
+	if( ext ) return allowedUploadFileExtensions.rawget(ext, "unknown");
+	return "unknown";
+}
+
 function sanitizePath(path){
 	//reorient separators
 	path=path.gsub("\\", "/");
@@ -310,8 +329,8 @@ local allowedEditFileExtensions = {
 
 function isExtensionAllowed(fname){
 	local ext;
-	fname.gmatch("(%.?[^%.\\/]*)$", @(m) ext=m)
-	if( ext ) return allowedEditFileExtensions.get(ext, false);
+	fname.gmatch("(%.?[^%.\\/]*)$", @(m) ext=m);
+	if( ext ) return allowedEditFileExtensions.rawget(ext, false);
 	return false;
 }
 
@@ -410,8 +429,8 @@ local uri_handlers = {
 		//password protected
 		bool_t canEdit = false;
 		//print("EDIT_MD5_PASSWORD=", EDIT_MD5_PASSWORD, "\n")
-		bool_t isViewOnly = globals.get("VIEW_MD5_PASSWORD", false) && request.check_password(VIEW_MD5_PASSWORD);
-		if (!isViewOnly) canEdit = globals.get("EDIT_MD5_PASSWORD", false) && request.check_password(EDIT_MD5_PASSWORD);
+		bool_t isViewOnly = globals.rawget("VIEW_MD5_PASSWORD", false) && request.check_password(VIEW_MD5_PASSWORD);
+		if (!isViewOnly) canEdit = globals.rawget("EDIT_MD5_PASSWORD", false) && request.check_password(EDIT_MD5_PASSWORD);
 
 		if(!(canEdit || isViewOnly) ) {
 			request.send_authorization_request("r.dadbiz.es");
@@ -427,8 +446,8 @@ local uri_handlers = {
 		bool_t isPost = request.info.request_method == "POST";
 		if (isPost && canEdit) {
 			local post_fields = get_post_fields(request);
-			if (post_fields.get("save", false)) {
-				local content = post_fields.get("content", null);
+			if (post_fields.rawget("save", false)) {
+				local content = post_fields.rawget("content", null);
 				if (content){
 					data.file_name <- sanitizePath(post_fields.file_name);
 					if (!isExtensionAllowed(data.file_name)) data.file_name = NULL;
@@ -474,11 +493,11 @@ function add_uri_hanlders(tbl){
 	foreach(k,v in tbl) uri_handlers[k] <- v;
 }
 
-if(AT_DEV_DBG || !globals.get("checkCompaniesUkDBFile", false)) {
+if(AT_DEV_DBG || !globals.rawget("checkCompaniesUkDBFile", false)) {
 	dofile(APP_CODE_FOLDER + "/companies-uk.nut");
 }
 
-if(AT_DEV_DBG || !globals.get("ourbizDB", false)) {
+if(AT_DEV_DBG || !globals.rawget("ourbizDB", false)) {
 	dofile(APP_CODE_FOLDER + "/ourbiz.nut");
 }
 
@@ -486,7 +505,7 @@ local ourbiz_password = md5("mingote:ourbiz.dadbiz.es:tr14pink");
 function handle_request(request){
 	//static content served by mongoose directly
 	local request_uri = request.info.uri;
-	//debug_print(request.get_option("document_root"), request_uri, "\n")
+	//debug_print(request.get_option("document_root"), "::", request_uri, "\n")
 	if(request_uri.startswith("/DB/")){
 		if(!request.check_password(ourbiz_password)) {
 			request.send_authorization_request("ourbiz.dadbiz.es");
@@ -495,6 +514,6 @@ function handle_request(request){
 	}
 	if (request_uri.endswith(".js") || request_uri.endswith(".css") ) return false;
 	if (request_uri == "/index.html" || request_uri == "/" ) return uri_handlers["/search"](request);
-	if( uri_handlers.get(request_uri, false) ) return uri_handlers[request_uri](request);
+	if( uri_handlers.rawget(request_uri, false) ) return uri_handlers[request_uri](request);
 	return false;
 }

+ 5 - 4
SquiLu-ourbiz/sq-server.nut

@@ -5,7 +5,7 @@
  */
  
 local globals = getroottable();
-if(!globals.get("APP_CODE_FOLDER", false)) ::APP_CODE_FOLDER <- ".";
+if(!globals.rawget("APP_CODE_FOLDER", false)) ::APP_CODE_FOLDER <- ".";
 
 WIN32 <- os.getenv("WINDIR") != null;
 
@@ -24,15 +24,15 @@ function getUserCallbackSetup(fn){
 	fd.close();
 	local extra_code = format("APP_CODE_FOLDER <- \"%s\";\n", APP_CODE_FOLDER);
 
-	if (globals.get("VIEW_MD5_PASSWORD", false)){
+	if (globals.rawget("VIEW_MD5_PASSWORD", false)){
 		extra_code += format("VIEW_MD5_PASSWORD <- \"%s\";\n", VIEW_MD5_PASSWORD);
 	} else extra_code += "VIEW_MD5_PASSWORD <- false;\n";
 
-	if (globals.get("EDIT_MD5_PASSWORD", false)){
+	if (globals.rawget("EDIT_MD5_PASSWORD", false)){
 		extra_code += format("EDIT_MD5_PASSWORD <- \"%s\";\n", EDIT_MD5_PASSWORD);
 	} else extra_code += "EDIT_MD5_PASSWORD <- false;\n";
 
-	if (globals.get("AT_DEV_DBG", false)){
+	if (globals.rawget("AT_DEV_DBG", false)){
 		extra_code += "AT_DEV_DBG <- true;\n"
 	} else extra_code += "AT_DEV_DBG <- false;\n"
 
@@ -70,6 +70,7 @@ local mongoose_start_params = {
 				dofile(APP_CODE_FOLDER + "/sq-server-plugin.nut");
 			}
 			try {
+				//debug_print("\nHttp :\n", request.info.uri);
 				return handle_request(request);
 			}
 			catch(exep){