webmcp
diff demo-app/config/demo.lua @ 0:9fdfb27f8e67
Version 1.0.0
author | jbe/bsw |
---|---|
date | Sun Oct 25 12:00:00 2009 +0100 (2009-10-25) |
parents | |
children | 72860d232f32 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/demo-app/config/demo.lua Sun Oct 25 12:00:00 2009 +0100 1.3 @@ -0,0 +1,47 @@ 1.4 +-- uncomment the following two lines to use C implementations of chosen 1.5 +-- functions and to disable garbage collection during the request, to 1.6 +-- increase speed: 1.7 +-- 1.8 +-- require 'webmcp_accelerator' 1.9 +-- collectgarbage("stop") 1.10 + 1.11 +-- open and set default database handle 1.12 +db = assert(mondelefant.connect{ 1.13 + engine='postgresql', 1.14 + dbname='webmcp_demo' 1.15 +}) 1.16 +at_exit(function() 1.17 + db:close() 1.18 +end) 1.19 +function mondelefant.class_prototype:get_db_conn() return db end 1.20 + 1.21 +-- enable output of SQL commands in trace system 1.22 +function db:sql_tracer(command) 1.23 + return function(error_info) 1.24 + local error_info = error_info or {} 1.25 + trace.sql{ command = command, error_position = error_info.position } 1.26 + end 1.27 +end 1.28 + 1.29 +-- 'request.get_relative_baseurl()' should be replaced by the absolute 1.30 +-- base URL of the application, as otherwise HTTP redirects will not be 1.31 +-- standard compliant 1.32 +request.set_absolute_baseurl(request.get_relative_baseurl()) 1.33 + 1.34 +-- uncomment the following lines, if you want to use a database driven 1.35 +-- tempstore (for flash messages): 1.36 +-- 1.37 +-- function tempstore.save(blob) 1.38 +-- return Tempstore:create(blob) 1.39 +-- end 1.40 +-- function tempstore.pop(key) 1.41 +-- return Tempstore:data_by_key(key) 1.42 +-- end 1.43 + 1.44 + 1.45 +function mondelefant.class_prototype:by_id(id) 1.46 + return self:new_selector() 1.47 + :add_where{ "id = ?", id } 1.48 + :optional_object_mode() 1.49 + :exec() 1.50 +end