webmcp

annotate demo-app/config/demo.lua @ 88:c743d80859cf

Added tag v1.2.4 for changeset a5106c0a9be4
author jbe
date Fri Jul 06 12:54:26 2012 +0200 (2012-07-06)
parents 72860d232f32
children 2169a62e12f5
rev   line source
jbe/bsw@0 1 -- uncomment the following two lines to use C implementations of chosen
jbe/bsw@0 2 -- functions and to disable garbage collection during the request, to
jbe/bsw@0 3 -- increase speed:
jbe/bsw@0 4 --
jbe/bsw@0 5 -- require 'webmcp_accelerator'
jbe/bsw@0 6 -- collectgarbage("stop")
jbe/bsw@0 7
jbe/bsw@0 8 -- open and set default database handle
jbe/bsw@0 9 db = assert(mondelefant.connect{
jbe/bsw@0 10 engine='postgresql',
jbe/bsw@0 11 dbname='webmcp_demo'
jbe/bsw@0 12 })
jbe/bsw@0 13 at_exit(function()
jbe/bsw@0 14 db:close()
jbe/bsw@0 15 end)
jbe/bsw@0 16 function mondelefant.class_prototype:get_db_conn() return db end
jbe/bsw@0 17
jbe/bsw@0 18 -- enable output of SQL commands in trace system
jbe/bsw@0 19 function db:sql_tracer(command)
jbe/bsw@0 20 return function(error_info)
jbe/bsw@0 21 local error_info = error_info or {}
jbe/bsw@0 22 trace.sql{ command = command, error_position = error_info.position }
jbe/bsw@0 23 end
jbe/bsw@0 24 end
jbe/bsw@0 25
jbe/bsw@0 26 -- 'request.get_relative_baseurl()' should be replaced by the absolute
jbe/bsw@0 27 -- base URL of the application, as otherwise HTTP redirects will not be
jbe/bsw@0 28 -- standard compliant
jbe/bsw@0 29 request.set_absolute_baseurl(request.get_relative_baseurl())
jbe/bsw@0 30
jbe/bsw@0 31 -- uncomment the following lines, if you want to use a database driven
jbe/bsw@0 32 -- tempstore (for flash messages):
jbe/bsw@0 33 --
jbe/bsw@0 34 -- function tempstore.save(blob)
jbe/bsw@0 35 -- return Tempstore:create(blob)
jbe/bsw@0 36 -- end
jbe/bsw@0 37 -- function tempstore.pop(key)
jbe/bsw@0 38 -- return Tempstore:data_by_key(key)
jbe/bsw@0 39 -- end
jbe/bsw@0 40
jbe/bsw@0 41
jbe/bsw@0 42 function mondelefant.class_prototype:by_id(id)
jbe/bsw@0 43 return self:new_selector()
jbe/bsw@0 44 :add_where{ "id = ?", id }
jbe/bsw@0 45 :optional_object_mode()
jbe/bsw@0 46 :exec()
jbe/bsw@0 47 end
jbe/bsw@2 48

Impressum / About Us