diff options
-rw-r--r-- | app/acf_cli-controller.lua | 10 | ||||
-rwxr-xr-x | bin/acf-cli | 15 | ||||
-rwxr-xr-x | lua/mvc.lua | 3 |
3 files changed, 13 insertions, 15 deletions
diff --git a/app/acf_cli-controller.lua b/app/acf_cli-controller.lua index 295bd47..f3b7d6f 100644 --- a/app/acf_cli-controller.lua +++ b/app/acf_cli-controller.lua @@ -2,6 +2,8 @@ module(..., package.seeall) require("posix") +local parent_exception_handler + mvc = {} mvc.on_load = function (self, parent) -- Make sure we have some kind of sane defaults for libdir @@ -11,6 +13,8 @@ mvc.on_load = function (self, parent) self.conf.default_controller = "welcome" self.conf.viewtype = "serialized" + parent_exception_handler = parent.exception_handler + -- this sets the package path for us and our children for p in string.gmatch(self.conf.libdir, "[^,]+") do package.path= p .. "?.lua;" .. package.path @@ -26,18 +30,16 @@ end mvc.post_exec = function () end ---[[ view_resolver = function(self) return function (viewtable) print(session.serialize("result", viewtable)) end end ---]] ---[[ The parent exception handler is just fine + exception_handler = function (self, message ) print(session.serialize("exception", message)) + parent_exception_handler(self, message) end ---]] redirect = function (self, str, result) return result diff --git a/bin/acf-cli b/bin/acf-cli index a0560a7..d2f7006 100755 --- a/bin/acf-cli +++ b/bin/acf-cli @@ -21,27 +21,22 @@ end require("posix") mvc = require("acf.mvc") --- this is to get around having to store --- the config file in /etc/helloworld/helloworld.conf -ENV={} -ENV.HOME="." FRAMEWORK=mvc:new() FRAMEWORK:read_config("acf") APP=FRAMEWORK:new("acf_cli") -- command line will have URI-type string defining prefix/controller/action --- (put into ENV.PATH_INFO) -- followed by parameters --- (put into APP.clientdata) -APP.clientdata = {} +local p,c,a = APP.parse_path_info(arg[1]) +local clientdata = {} for i=2,#arg do a,v = string.match(arg[i], "([^=]*)=(.*)") if v then - APP.clientdata[a] = v + clientdata[a] = v else - APP.clientdata[arg[i]] = true + clientdata[arg[i]] = true end end -APP:dispatch(APP.parse_path_info(arg[1])) +APP:dispatch(p,c,a,clientdata) APP:destroy() FRAMEWORK:destroy() diff --git a/lua/mvc.lua b/lua/mvc.lua index ca5bc8e..bd69051 100755 --- a/lua/mvc.lua +++ b/lua/mvc.lua @@ -124,13 +124,14 @@ destroy = function (self) end -- This is a sample front controller/dispatch. -dispatch = function (self, userprefix, userctlr, useraction) +dispatch = function (self, userprefix, userctlr, useraction, clientdata) local controller = nil local success, err = xpcall ( function () self.conf.prefix = userprefix or "/" self.conf.controller = userctlr or "" self.conf.action = useraction or "" + if clientdata then self.clientdata = clientdata end -- If they didn't provide a controller, and a default was specified -- use it |