webmcp
view demo-app/config/demo.lua @ 2:72860d232f32
Version 1.0.2
Fixed bug with explicit garbage collection (requests > 256kB caused an error)
Views prefixed with an underscore can't be called externally
ui.paginate now displays the last page, if the selected page number is too high.
Fixed bug with explicit garbage collection (requests > 256kB caused an error)
Views prefixed with an underscore can't be called externally
ui.paginate now displays the last page, if the selected page number is too high.
author | jbe/bsw |
---|---|
date | Thu Dec 10 12:00:00 2009 +0100 (2009-12-10) |
parents | 9fdfb27f8e67 |
children | 2169a62e12f5 |
line source
1 -- uncomment the following two lines to use C implementations of chosen
2 -- functions and to disable garbage collection during the request, to
3 -- increase speed:
4 --
5 -- require 'webmcp_accelerator'
6 -- collectgarbage("stop")
8 -- open and set default database handle
9 db = assert(mondelefant.connect{
10 engine='postgresql',
11 dbname='webmcp_demo'
12 })
13 at_exit(function()
14 db:close()
15 end)
16 function mondelefant.class_prototype:get_db_conn() return db end
18 -- enable output of SQL commands in trace system
19 function db:sql_tracer(command)
20 return function(error_info)
21 local error_info = error_info or {}
22 trace.sql{ command = command, error_position = error_info.position }
23 end
24 end
26 -- 'request.get_relative_baseurl()' should be replaced by the absolute
27 -- base URL of the application, as otherwise HTTP redirects will not be
28 -- standard compliant
29 request.set_absolute_baseurl(request.get_relative_baseurl())
31 -- uncomment the following lines, if you want to use a database driven
32 -- tempstore (for flash messages):
33 --
34 -- function tempstore.save(blob)
35 -- return Tempstore:create(blob)
36 -- end
37 -- function tempstore.pop(key)
38 -- return Tempstore:data_by_key(key)
39 -- end
42 function mondelefant.class_prototype:by_id(id)
43 return self:new_selector()
44 :add_where{ "id = ?", id }
45 :optional_object_mode()
46 :exec()
47 end