diff options
author | Nathan Angelacos <nangel@tetrasec.net> | 2007-11-02 21:01:45 +0000 |
---|---|---|
committer | Nathan Angelacos <nangel@tetrasec.net> | 2007-11-02 21:01:45 +0000 |
commit | ee27a6341f094e239837c7077e86b0c7f0c306bc (patch) | |
tree | a628d69ea056990baf3bb5a2bcfadcb0aa27ae3b /www/cgi-bin | |
parent | d49ec1941b5621f47662c422c0557d62385583bd (diff) | |
download | acf-core-ee27a6341f094e239837c7077e86b0c7f0c306bc.tar.bz2 acf-core-ee27a6341f094e239837c7077e86b0c7f0c306bc.tar.xz |
mvc.lua - change new to return 3 values, new mvc object,
and a boolean each for the status of loading the named controller and model
acf_www-controller.lua - example showing how to cope if the mvc:new returns
with a missing model/controller
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@266 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'www/cgi-bin')
-rwxr-xr-x | www/cgi-bin/mvc.lua | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/www/cgi-bin/mvc.lua b/www/cgi-bin/mvc.lua index 23a71c7..4fe2954 100755 --- a/www/cgi-bin/mvc.lua +++ b/www/cgi-bin/mvc.lua @@ -1,5 +1,6 @@ --[[ Basic MVC framework - Written for Alpine Configuration Framework (ACF) -- see www.alpinelinux.org + Written for Alpine Configuration Framework (ACF) + see www.alpinelinux.org for more information Copyright (C) 2007 Nathan Angelacos Licensed under the terms of GPL2 ]]-- @@ -18,13 +19,16 @@ module(..., package.seeall) ]] new = function (self, modname) + local model_loaded = true + local worker_loaded = true local c = {} c.worker = {} c.model = {} -- make defaults if the parent doesn't have them if self.conf == nil then - c.conf = { appdir = "", confdir = "", tempdir = "", appname = "" } + c.conf = { appdir = "", confdir = "", + tempdir = "", appname = "" } end -- If no clientdata, then clientdata is a null table @@ -39,8 +43,16 @@ new = function (self, modname) -- load the module code here if (modname) then - c.worker = self:soft_require( modname .. "-controller") or {} - c.model = self:soft_require( modname .. "-model" ) or {} + c.worker = self:soft_require( modname .. "-controller") + if c.worker == nil then + c.worker = {} + worker_loaded = false + end + c.model = self:soft_require( modname .. "-model" ) + if c.model == nil then + c.model = {} + model_loaded = false + end end -- The magic that makes all the metatables point in the correct @@ -81,7 +93,7 @@ new = function (self, modname) c.worker.mvc.on_load = nil end - return c + return c worker_loaded model_loaded end -- This is a sample front controller/dispatch. |