summaryrefslogtreecommitdiffstats
path: root/app/acf_cli-controller.lua
blob: 228706793e4b49f8670fc5886661d72728e626ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
module(..., package.seeall)

-- We use the parent exception handler in a last-case situation
local parent_exception_handler

mvc = {}
mvc.on_load = function (self, parent)
	
	-- Make sure we have some kind of sane defaults for libdir and sessiondir
	self.conf.libdir = self.conf.libdir or ( self.conf.appdir .. "/lib/" )
	self.conf.sessiondir = self.conf.sessiondir or "/tmp/"
	self.conf.appuri = ""
	self.conf.default_controller = "welcome"	

	parent_exception_handler = parent.exception_handler
	
	-- this sets the package path for us and our children
	package.path=  self.conf.libdir .. "?.lua;" .. package.path

	self.session = {}
	local x=require("session")
end

mvc.pre_exec = function ()
end

mvc.post_exec = function ()
end


view_resolver = function(self)
    return function (viewtable)
        print(viewtable)
    end
end

exception_handler = function (self, message )
    print(message)
end

-- create a Configuration Framework Entity (cfe) 
-- returns a table with at least "value", "type", "option" and "errtxt"
cfe = function ( optiontable )
	optiontable = optiontable or {}
	me = { 	value="",
		type="text",
		option="",
		errtxt="",
		name=""  }
	for key,value in pairs(optiontable) do
		me[key] = value
	end
	return me
end


-- syslog something
logit = function ( ... )
	os.execute ( "logger \"" .. ... .. "\"" )
end