From ee27a6341f094e239837c7077e86b0c7f0c306bc Mon Sep 17 00:00:00 2001 From: Nathan Angelacos Date: Fri, 2 Nov 2007 21:01:45 +0000 Subject: 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 --- app/acf_www-controller.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'app/acf_www-controller.lua') diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua index 742533a..4f5b755 100644 --- a/app/acf_www-controller.lua +++ b/app/acf_www-controller.lua @@ -119,12 +119,24 @@ view_resolver = function(self) -- with conf, and other "missing" parts pointing back -- to APP or self -- *************************************************** - local m = self:new("alpine-baselayout/hostname") - local h = m.worker.read(m) + local m,worker_loaded,model_loaded = self:new("alpine-baselayout/hostname") + + -- FIXME - this is ugly, but it puts the hostname the expected + -- format if the controller doesn't load correctly + local h = {} + + -- If the worker and model loaded correctly, then + -- use the sub-controller + if worker_loaded && model_loaded then + h = m.worker.read(m) + else + h.hostname = { value = "unknown" } + end local pageinfo = { viewfile = viewname, controller = m.conf.controller, -- ^^^ see.. m.conf doesnt exist - but it works + -- the inheritance means self.conf is used instead action = self.conf.action, hostname = h.hostname.value, prefix = self.conf.prefix, -- cgit v1.2.3