From 6a6e0c812beafc4a2b6304c8b17fae317035a898 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 17 Nov 2008 19:47:28 +0000 Subject: Modified mvc to create a stack of self pointers as controllers are created. Modelfunctions write_file_with_audit uses the stack to find self for auditing. git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1595 ab2d0c66-481e-0410-8bed-d214d4d58bed --- www/cgi-bin/mvc.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'www/cgi-bin') diff --git a/www/cgi-bin/mvc.lua b/www/cgi-bin/mvc.lua index 4ded73d..a36878c 100755 --- a/www/cgi-bin/mvc.lua +++ b/www/cgi-bin/mvc.lua @@ -93,6 +93,10 @@ new = function (self, modname) c.worker.mvc.on_load = nil end + -- save the new self on the SELF stack + if not SELF then SELF = {} end + SELF[#SELF + 1] = c + return c, worker_loaded, model_loaded end @@ -101,6 +105,16 @@ destroy = function (self) self.worker.mvc.on_unload(self) self.worker.mvc.on_unload = nil end + + -- remove the self from the SELF stack (should be at the end, but just in case) + if SELF then + for i,s in ipairs(SELF) do + if s == self then + table.remove(SELF, i) + break + end + end + end end -- This is a sample front controller/dispatch. -- cgit v1.2.3