bsw@729: request.set_404_route{ module = 'index', view = '404' } bsw@729: bsw@729: -- open and set default database handle bsw@729: db = assert(mondelefant.connect{ bsw@729: engine='postgresql', bsw@729: dbname='liquid_feedback' bsw@729: }) bsw@729: at_exit(function() bsw@729: db:close() bsw@729: end) bsw@729: function mondelefant.class_prototype:get_db_conn() return db end bsw@729: bsw@729: -- enable output of SQL commands in trace system bsw@729: function db:sql_tracer(command) bsw@729: return function(error_info) bsw@729: local error_info = error_info or {} bsw@729: trace.sql{ command = command, error_position = error_info.position } bsw@729: end bsw@729: end bsw@729: bsw@729: request.set_absolute_baseurl(config.absolute_base_url) bsw@729: bsw@729: bsw@729: bsw@729: -- TODO abstraction bsw@729: -- get record by id bsw@729: function mondelefant.class_prototype:by_id(id) bsw@729: local selector = self:new_selector() bsw@729: selector:add_where{ 'id = ?', id } bsw@729: selector:optional_object_mode() bsw@729: return selector:exec() bsw@729: end bsw@729: