Commit 2235d756dfab91fc63af0665491c6fbbd339f164

Authored by totoro
1 parent d937aea4

fix getting bool from web_arg with default value which the found value case was …

…not evaluated to the right boolean value. Because the name was found the previous version always return 'true' as value, but it's not necessary the right value.
Showing 1 changed file with 25 additions and 6 deletions   Show diff stats
web/CXM_web_arg_utils.anubis
... ... @@ -295,15 +295,23 @@ public define Maybe(Bool)
295 295 List(Web_arg) lwa,
296 296 String arg_name
297 297 ) =
  298 +// println("get_mb_Bool "+arg_name);
298 299 if web_arg_value(lwa, arg_name) is
299 300 {
300 301 not_found then
301 302 if web_arg_value(lwa, "~"+arg_name) is
302 303 {
303   - not_found then failure,
304   - found(_) then success(false)
  304 + not_found then
  305 + //println("failure");
  306 + failure,
  307 + found(_) then
  308 + //println("success(false)");
  309 + success(false)
305 310 },
306   - found(_) then success(true)
  311 + found(value) then
  312 + with return_v = to_Bool(value),
  313 +// println("value = '"+value+"' result = "+to_String(return_v)+" success("+to_String(return_v)+")");
  314 + success(return_v)
307 315 }.
308 316  
309 317 public define Bool
... ... @@ -312,10 +320,14 @@ public define Bool
312 320 List(Web_arg) lwa,
313 321 String arg_name
314 322 ) =
  323 +// println("get_Bool "+arg_name);
315 324 if web_arg_value(lwa, arg_name) is
316 325 {
317 326 not_found then false,
318   - found(value) then to_Bool(value)
  327 + found(value) then
  328 + with return_v = to_Bool(value),
  329 +// println("value = '"+value+"' result = "+to_String(return_v));
  330 + return_v
319 331 }.
320 332  
321 333 public define Bool
... ... @@ -325,10 +337,17 @@ public define Bool
325 337 String arg_name,
326 338 Bool default_value
327 339 ) =
  340 +// println("get_Bool with default ["+arg_name+"] default = "+to_String(default_value));
328 341 if web_arg_value(lwa, arg_name) is
329 342 {
330   - not_found then default_value,
331   - found(_) then true
  343 + not_found then
  344 + //println("return default_value");
  345 + default_value,
  346 + found(value) then
  347 + with return_v = to_Bool(value),
  348 + //println("value = '"+value+"' result = "+to_String(return_v));
  349 + return_v
  350 + //true
332 351 }.
333 352  
334 353 public define Maybe(Bool)
... ...