liquid_feedback_frontend
diff config/init.lua @ 1145:904f6807f7fa
Added support for upcoming moonbridge bases WebMCP
author | bsw |
---|---|
date | Sat Mar 21 15:26:39 2015 +0100 (2015-03-21) |
parents | a3a1a6afcf68 |
children | 24787d0d9317 |
line diff
1.1 --- a/config/init.lua Sat Mar 21 15:03:39 2015 +0100 1.2 +++ b/config/init.lua Sat Mar 21 15:26:39 2015 +0100 1.3 @@ -56,33 +56,10 @@ 1.4 config.database = { engine='postgresql', dbname='liquid_feedback' } 1.5 end 1.6 1.7 -if not config.enable_debug_trace then 1.8 - trace.disable() 1.9 -else 1.10 - slot.put_into('trace_button', '<div id="trace_show" onclick="document.getElementById(\'trace_content\').style.display=\'block\';this.style.display=\'none\';">TRACE</div>') 1.11 -end 1.12 - 1.13 - 1.14 request.set_404_route{ module = 'index', view = '404' } 1.15 1.16 --- open and set default database handle 1.17 -db = assert(mondelefant.connect(config.database)) 1.18 -at_exit(function() 1.19 - db:close() 1.20 -end) 1.21 -function mondelefant.class_prototype:get_db_conn() return db end 1.22 - 1.23 --- enable output of SQL commands in trace system 1.24 -function db:sql_tracer(command) 1.25 - return function(error_info) 1.26 - local error_info = error_info or {} 1.27 - trace.sql{ command = command, error_position = error_info.position } 1.28 - end 1.29 -end 1.30 - 1.31 request.set_absolute_baseurl(config.absolute_base_url) 1.32 1.33 - 1.34 -- TODO abstraction 1.35 -- get record by id 1.36 function mondelefant.class_prototype:by_id(id) 1.37 @@ -92,3 +69,76 @@ 1.38 return selector:exec() 1.39 end 1.40 1.41 +-- compatibility for WebMCP 1.2.6 1.42 +if not listen then 1.43 + 1.44 + -- open and set default database handle 1.45 + _G.db = assert(mondelefant.connect(config.database)) 1.46 + 1.47 + function mondelefant.class_prototype:get_db_conn() return db end 1.48 + 1.49 + -- enable output of SQL commands in trace system 1.50 + function db:sql_tracer(command) 1.51 + return function(error_info) 1.52 + local error_info = error_info or {} 1.53 + trace.sql{ command = command, error_position = error_info.position } 1.54 + end 1.55 + end 1.56 + 1.57 + -- close the database at exit 1.58 + at_exit(function() 1.59 + db:close() 1.60 + end) 1.61 + 1.62 + function request.get_cookie(args) 1.63 + return cgi.cookies[args.name] 1.64 + end 1.65 + 1.66 + function request.get_param(args) 1.67 + return request.get_param_strings()[args.name] 1.68 + end 1.69 + 1.70 + function request.add_header(key, value) 1.71 + print(key .. ": " .. value) 1.72 + end 1.73 + 1.74 + local request_redirect = request.redirect 1.75 + function request.redirect(args) 1.76 + if args.static then 1.77 + print('Location: ' .. encode.url{ static = args.static } .. '\n\n') 1.78 + exit() 1.79 + else 1.80 + request_redirect(args) 1.81 + end 1.82 + end 1.83 + 1.84 + 1.85 + return 1.86 +end 1.87 + 1.88 +if not config.fork then 1.89 + config.fork = {} 1.90 +end 1.91 + 1.92 +if not config.fork.pre then 1.93 + config.fork.pre = 4 1.94 +end 1.95 + 1.96 +if not config.fork.max then 1.97 + config.fork.max = 8 1.98 +end 1.99 + 1.100 +if not config.fork.delay then 1.101 + config.fork.delay = 1 1.102 +end 1.103 + 1.104 +if not config.port then 1.105 + config.port = 8080 1.106 +end 1.107 + 1.108 +listen{ 1.109 + { proto = "tcp4", port = config.port, localhost = true }, 1.110 + pre_fork = config.fork.pre, 1.111 + max_fork = config.fork.max, 1.112 + fork_delay = config.fork.delay 1.113 +}